TestApplet: add test for EC without W

This commit is contained in:
Arnaud Fontaine
2018-12-06 11:02:16 +01:00
parent b5567df674
commit a9e52ab31b
2 changed files with 24 additions and 3 deletions

View File

@@ -141,14 +141,14 @@ public final class TestApplet extends Applet {
}
private final void processTestEc(final byte p1, final byte p2) {
boolean generate;
boolean generate, provide_w;
short size;
ECPrivateKey priv;
ECPublicKey pub;
byte[] field, a, b, g, r, s, w;
short k;
switch(p1) {
switch(p1 & (byte)0x01) {
case (byte)0x00:
generate = false;
break;
@@ -162,6 +162,20 @@ public final class TestApplet extends Applet {
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) {
case (byte)0x00:
size = 256;
@@ -237,7 +251,9 @@ public final class TestApplet extends Applet {
kp.genKeyPair();
} else {
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()) {