diff options
Diffstat (limited to 'src/cz/crcs/ectester/applet/ECTesterApplet.java')
| -rw-r--r-- | src/cz/crcs/ectester/applet/ECTesterApplet.java | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/cz/crcs/ectester/applet/ECTesterApplet.java b/src/cz/crcs/ectester/applet/ECTesterApplet.java index e17d102..f9fb5da 100644 --- a/src/cz/crcs/ectester/applet/ECTesterApplet.java +++ b/src/cz/crcs/ectester/applet/ECTesterApplet.java @@ -52,6 +52,7 @@ public class ECTesterApplet extends Applet { public static final byte INS_ECDH = (byte) 0x60; public static final byte INS_ECDSA = (byte) 0x61; public static final byte INS_CLEANUP = (byte) 0x62; + public static final byte INS_SUPPORT = (byte) 0x63; // PARAMETERS for P1 and P2 public static final byte KEYPAIR_LOCAL = (byte) 0x01; @@ -74,10 +75,13 @@ public class ECTesterApplet extends Applet { private RandomData randomData = null; - private KeyPair localKeypair = null; - private KeyPair remoteKeypair = null; private ECKeyTester keyTester = null; + private short ecdhSW; + private short ecdhcSW; + private short ecdsaSW; private ECKeyGenerator keyGenerator = null; + private KeyPair localKeypair = null; + private KeyPair remoteKeypair = null; protected ECTesterApplet(byte[] buffer, short offset, byte length) { if (length > 9) { @@ -102,9 +106,9 @@ public class ECTesterApplet extends Applet { keyGenerator = new ECKeyGenerator(); keyTester = new ECKeyTester(); - keyTester.allocateECDH(); - keyTester.allocateECDHC(); - keyTester.allocateECDSA(); + ecdhSW = keyTester.allocateECDH(); + ecdhcSW = keyTester.allocateECDHC(); + ecdsaSW = keyTester.allocateECDSA(); } register(); } @@ -152,6 +156,9 @@ public class ECTesterApplet extends Applet { case INS_CLEANUP: insCleanup(apdu); break; + case INS_SUPPORT: + insSupport(apdu); + break; default: // The INS code is not supported by the dispatcher ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED); @@ -375,6 +382,7 @@ public class ECTesterApplet extends Applet { /** * + * @param apdu */ private void insCleanup(APDU apdu) { apdu.setIncomingAndReceive(); @@ -386,6 +394,19 @@ public class ECTesterApplet extends Applet { } /** + * + * @param apdu + */ + private void insSupport(APDU apdu) { + apdu.setIncomingAndReceive(); + byte[] apdubuf = apdu.getBuffer(); + + short len = support(apdubuf, (short) 0); + + apdu.setOutgoingAndSend((short) 0, len); + } + + /** * @param keyPair which keyPair to use, local/remote (KEYPAIR_* | ...) * @param keyLength key length to set * @param keyClass key class to allocate @@ -606,4 +627,19 @@ public class ECTesterApplet extends Applet { Util.setShort(buffer, offset, sw); return 2; } + + /** + * + * @param buffer + * @param offset + * @return + */ + private short support(byte[] buffer, short offset) { + + Util.setShort(buffer, offset, ecdhSW); + Util.setShort(buffer, (short) (offset+2), ecdhcSW); + Util.setShort(buffer, (short) (offset+4), ecdsaSW); + + return 6; + } } |
