aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpetrs2016-10-04 12:31:41 +0200
committerpetrs2016-10-04 12:31:41 +0200
commitebc1e25953a54b5f6815e2989a951bab06d84bdd (patch)
tree9b71c23017d5b603e2d61bfd09c04604802f34c1
parent8395251ac26f1f4fd8168907d72d08146732b4e3 (diff)
downloadECTester-ebc1e25953a54b5f6815e2989a951bab06d84bdd.tar.gz
ECTester-ebc1e25953a54b5f6815e2989a951bab06d84bdd.tar.zst
ECTester-ebc1e25953a54b5f6815e2989a951bab06d84bdd.zip
-rw-r--r--!uploader/gppro_upload_emv.bat6
-rw-r--r--dist/SimpleAPDU.jarbin43458 -> 45888 bytes
-rw-r--r--src/simpleapdu/SimpleAPDU.java41
3 files changed, 26 insertions, 21 deletions
diff --git a/!uploader/gppro_upload_emv.bat b/!uploader/gppro_upload_emv.bat
index 8d757a0..a9b0b9c 100644
--- a/!uploader/gppro_upload_emv.bat
+++ b/!uploader/gppro_upload_emv.bat
@@ -1,5 +1,7 @@
-gp.exe -delete 4C6162616B417070 -deletedeps -verbose -emv
-gp.exe -deletedeps -verbose -emv -delete 4A43416C6754657374
+gp.exe -deletedeps -verbose -emv -delete 4C6162616B417070
+gp.exe -deletedeps -verbose -emv -delete 4A43416C6754657374
+gp.exe -deletedeps -verbose -emv -delete 4543546573746572
+
gp.exe -install simpleECC.cap -verbose -emv -d
diff --git a/dist/SimpleAPDU.jar b/dist/SimpleAPDU.jar
index 8f8ff3f..c2cf0cc 100644
--- a/dist/SimpleAPDU.jar
+++ b/dist/SimpleAPDU.jar
Binary files differ
diff --git a/src/simpleapdu/SimpleAPDU.java b/src/simpleapdu/SimpleAPDU.java
index eb6a1b4..78d5bd8 100644
--- a/src/simpleapdu/SimpleAPDU.java
+++ b/src/simpleapdu/SimpleAPDU.java
@@ -19,11 +19,14 @@ public class SimpleAPDU {
private final static byte SELECT_ECTESTERAPPLET[] = {(byte) 0x00, (byte) 0xa4, (byte) 0x04, (byte) 0x00, (byte) 0x0a,
(byte) 0x45, (byte) 0x43, (byte) 0x54, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x65, (byte) 0x72, (byte) 0x30, (byte) 0x31};
- private static byte TESTECSUPPORTALL_FP[] = {(byte) 0xB0, (byte) 0x5E, (byte) 0x00, (byte) 0x00, (byte) 0x00};
- private static byte TESTECSUPPORTALL_F2M[] = {(byte) 0xB0, (byte) 0x5F, (byte) 0x00, (byte) 0x00, (byte) 0x00};
- private static byte TESTECSUPPORTALL_LASTUSEDPARAMS[] = {(byte) 0xB0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private static final byte TESTECSUPPORTALL_FP[] = {(byte) 0xB0, (byte) 0x5E, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private static final byte TESTECSUPPORTALL_F2M[] = {(byte) 0xB0, (byte) 0x5F, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private static final byte TESTECSUPPORTALL_LASTUSEDPARAMS[] = {(byte) 0xB0, (byte) 0x40, (byte) 0x00, (byte) 0x00, (byte) 0x00};
- private static byte TESTECSUPPORTALL_FP_KEYGEN_INVALIDCURVEB[] = {(byte) 0xB0, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private static final byte TESTECSUPPORTALL_FP_KEYGEN_INVALIDCURVEB[] = {(byte) 0xB0, (byte) 0x70, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private static final short INVALIDCURVEB_NUMREPEATS_OFFSET = 5;
+ private static final short INVALIDCURVEB_CORRUPTIONTYPE_OFFSET = 7;
+ private static final short INVALIDCURVEB_REWINDONSUCCESS_OFFSET = 9;
static short getShort(byte[] array, int offset) {
return (short) (((array[offset] & 0xFF) << 8) | (array[offset + 1] & 0xFF));
@@ -33,17 +36,13 @@ public class SimpleAPDU {
array[offset] = (byte) ((value >> 8) & 0xFF);
}
static void testFPkeyGen_setNumRepeats(byte[] apduArray, short numRepeats) {
- // num repeats starts at index 5
- setShort(apduArray, 5, numRepeats);
+ setShort(apduArray, INVALIDCURVEB_NUMREPEATS_OFFSET, numRepeats);
}
- static void testFPkeyGen_rewindOnSuccess(byte[] apduArray, boolean bRewind) {
- // rewind info at index 7
- apduArray[7] = bRewind ? (byte) 1 : (byte) 0;
- }
-
static void testFPkeyGen_setCorruptionType(byte[] apduArray, short corruptionType) {
- // corruptionType starts at index 7
- setShort(apduArray, 7, corruptionType);
+ setShort(apduArray, INVALIDCURVEB_CORRUPTIONTYPE_OFFSET, corruptionType);
+ }
+ static void testFPkeyGen_rewindOnSuccess(byte[] apduArray, boolean bRewind) {
+ apduArray[INVALIDCURVEB_REWINDONSUCCESS_OFFSET] = bRewind ? (byte) 1 : (byte) 0;
}
public static void main(String[] args) {
@@ -60,8 +59,8 @@ public class SimpleAPDU {
//testFPkeyGen_setCorruptionType(testAPDU, SimpleECCApplet.CORRUPT_B_LASTBYTEINCREMENT);
testFPkeyGen_setCorruptionType(testAPDU, SimpleECCApplet.CORRUPT_B_ONEBYTERANDOM);
//testFPkeyGen_setCorruptionType(testAPDU, SimpleECCApplet.CORRUPT_B_FULLRANDOM);
- testFPkeyGen_setNumRepeats(testAPDU, (short) 1000);
- testFPkeyGen_rewindOnSuccess(testAPDU, false);
+ testFPkeyGen_setNumRepeats(testAPDU, (short) 10);
+ testFPkeyGen_rewindOnSuccess(testAPDU, true);
ResponseAPDU resp_fp_keygen = cardManager.sendAPDU(testAPDU);
ResponseAPDU resp_keygen_params = cardManager.sendAPDU(TESTECSUPPORTALL_LASTUSEDPARAMS);
PrintECKeyGenInvalidCurveB(resp_fp_keygen);
@@ -125,11 +124,11 @@ public class SimpleAPDU {
}
static int VerifyPrintResult(String message, byte expectedTag, byte[] buffer, int bufferOffset, ExpResult expRes) {
if (bufferOffset >= buffer.length) {
- System.out.println("No more data returned");
+ System.out.println(" No more data returned");
}
else {
if (buffer[bufferOffset] != expectedTag) {
- System.out.println("ERROR: mismatched tag");
+ System.out.println(" ERROR: mismatched tag");
assert(buffer[bufferOffset] == expectedTag);
}
bufferOffset++;
@@ -155,7 +154,8 @@ public class SimpleAPDU {
static void PrintECSupport(ResponseAPDU resp) {
byte[] buffer = resp.getData();
- System.out.println();System.out.println();
+ System.out.println();
+ System.out.println("### Test for support and with valid and invalid EC curves");
int bufferOffset = 0;
while (bufferOffset < buffer.length) {
assert(buffer[bufferOffset] == SimpleECCApplet.ECTEST_SEPARATOR);
@@ -189,7 +189,7 @@ public class SimpleAPDU {
byte[] buffer = resp.getData();
System.out.println();
- System.out.println();
+ System.out.println("### Test for computation with invalid parameter B for EC curve");
int bufferOffset = 0;
while (bufferOffset < buffer.length) {
assert (buffer[bufferOffset] == SimpleECCApplet.ECTEST_SEPARATOR);
@@ -216,6 +216,9 @@ public class SimpleAPDU {
while (bufferOffset < buffer.length) {
bufferOffset = VerifyPrintResult("Set invalid custom curve:", SimpleECCApplet.ECTEST_SET_INVALIDCURVE, buffer, bufferOffset, ExpResult.SHOULD_SUCCEDD);
bufferOffset = VerifyPrintResult("Generate key with invalid curve (fail is good):", SimpleECCApplet.ECTEST_GENERATE_KEYPAIR_INVALIDCUSTOMCURVE, buffer, bufferOffset, ExpResult.MUST_FAIL);
+ if (buffer[bufferOffset] == SimpleECCApplet.ECTEST_DH_GENERATESECRET) {
+ bufferOffset = VerifyPrintResult("ECDH agreement with invalid point (fail is good):", SimpleECCApplet.ECTEST_DH_GENERATESECRET, buffer, bufferOffset, ExpResult.MUST_FAIL);
+ }
bufferOffset = VerifyPrintResult("Set valid custom curve:", SimpleECCApplet.ECTEST_SET_VALIDCURVE, buffer, bufferOffset, ExpResult.SHOULD_SUCCEDD);
bufferOffset = VerifyPrintResult("Generate key with valid curve:", SimpleECCApplet.ECTEST_GENERATE_KEYPAIR_CUSTOMCURVE, buffer, bufferOffset, ExpResult.SHOULD_SUCCEDD);
}