diff options
| author | J08nY | 2017-03-30 01:51:46 +0200 |
|---|---|---|
| committer | J08nY | 2017-03-30 01:51:46 +0200 |
| commit | 565d312568da433f213b3d7ea67861b7784b2115 (patch) | |
| tree | 7e3af1d28512e77b073105d5dc40c6e869633a3d /src/cz/crcs/ectester/applet/ECTesterApplet.java | |
| parent | 83c963ae78407e7a14ac71096f81254364d1e605 (diff) | |
| download | ECTester-565d312568da433f213b3d7ea67861b7784b2115.tar.gz ECTester-565d312568da433f213b3d7ea67861b7784b2115.tar.zst ECTester-565d312568da433f213b3d7ea67861b7784b2115.zip | |
Added more documentation, anomalous curves, support command.
- Added CURVES.md, FORMAT.md and TESTS.md that talk a bit about what
ECTester actually does/support.
- Added anomalous curves (where |F_p| = #|E(F_p)|), meaning these curves
have a trace of one and ECDLP over them reduces to easy DLP over
multiplicative F*_p. These concrete curves are from Atsuko Miyaji's
paper: Elliptic curves over F_p Suitable for Cryptosystems.
- Added Support command that queries the results of KeyAgreement and
Signature allocations.
- Renamed smallpub curves to nonprime curves.
- Fixed nonprime curves test suite.
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; + } } |
