TestApplet: add test for EC without W
This commit is contained in:
parent
b5567df674
commit
a9e52ab31b
@ -141,14 +141,14 @@ public final class TestApplet extends Applet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final void processTestEc(final byte p1, final byte p2) {
|
private final void processTestEc(final byte p1, final byte p2) {
|
||||||
boolean generate;
|
boolean generate, provide_w;
|
||||||
short size;
|
short size;
|
||||||
ECPrivateKey priv;
|
ECPrivateKey priv;
|
||||||
ECPublicKey pub;
|
ECPublicKey pub;
|
||||||
byte[] field, a, b, g, r, s, w;
|
byte[] field, a, b, g, r, s, w;
|
||||||
short k;
|
short k;
|
||||||
|
|
||||||
switch(p1) {
|
switch(p1 & (byte)0x01) {
|
||||||
case (byte)0x00:
|
case (byte)0x00:
|
||||||
generate = false;
|
generate = false;
|
||||||
break;
|
break;
|
||||||
@ -162,6 +162,20 @@ public final class TestApplet extends Applet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(p1 & (byte)0x10) {
|
||||||
|
case (byte)0x00:
|
||||||
|
provide_w = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (byte)0x10:
|
||||||
|
provide_w = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ISOException.throwIt(ISO7816.SW_WRONG_P1P2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch(p2) {
|
switch(p2) {
|
||||||
case (byte)0x00:
|
case (byte)0x00:
|
||||||
size = 256;
|
size = 256;
|
||||||
@ -237,7 +251,9 @@ public final class TestApplet extends Applet {
|
|||||||
kp.genKeyPair();
|
kp.genKeyPair();
|
||||||
} else {
|
} else {
|
||||||
priv.setS(s, (short)0, (short)s.length);
|
priv.setS(s, (short)0, (short)s.length);
|
||||||
pub.setW(w, (short)0, (short)w.length);
|
if(provide_w) {
|
||||||
|
pub.setW(w, (short)0, (short)w.length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!pub.isInitialized()) {
|
if(!pub.isInitialized()) {
|
||||||
|
@ -40,6 +40,9 @@ TEST_RSA_CRT_2048_GENERATE = [0x00, 0x02,
|
|||||||
TEST_EC_P256_STATIC = [0x00, 0x03,
|
TEST_EC_P256_STATIC = [0x00, 0x03,
|
||||||
0x00, 0x00];
|
0x00, 0x00];
|
||||||
|
|
||||||
|
TEST_EC_P256_STATIC_NO_W = [0x00, 0x03,
|
||||||
|
0x10, 0x00];
|
||||||
|
|
||||||
TEST_EC_P256_GENERATE = [0x00, 0x03,
|
TEST_EC_P256_GENERATE = [0x00, 0x03,
|
||||||
0x01, 0x00];
|
0x01, 0x00];
|
||||||
|
|
||||||
@ -123,6 +126,8 @@ def test_ec(con):
|
|||||||
select_applet(con, False)
|
select_applet(con, False)
|
||||||
send_apdu(con, "Test NIST P-256 static", TEST_EC_P256_STATIC)
|
send_apdu(con, "Test NIST P-256 static", TEST_EC_P256_STATIC)
|
||||||
select_applet(con, False)
|
select_applet(con, False)
|
||||||
|
send_apdu(con, "Test NIST P-256 static (without W)", TEST_EC_P256_STATIC_NO_W)
|
||||||
|
select_applet(con, False)
|
||||||
send_apdu(con, "Test NIST P-256 generate", TEST_EC_P256_GENERATE)
|
send_apdu(con, "Test NIST P-256 generate", TEST_EC_P256_GENERATE)
|
||||||
select_applet(con, False)
|
select_applet(con, False)
|
||||||
send_apdu(con, "Test NIST P-521 static", TEST_EC_P521_STATIC)
|
send_apdu(con, "Test NIST P-521 static", TEST_EC_P521_STATIC)
|
||||||
|
Loading…
Reference in New Issue
Block a user