aboutsummaryrefslogtreecommitdiff
path: root/src/simpleapdu/SimpleAPDU.java
diff options
context:
space:
mode:
authorJ08nY2016-12-11 14:20:00 +0100
committerJ08nY2016-12-11 14:20:00 +0100
commitda1ee8381f2f7eaf1cfcd4941ec9f95287435625 (patch)
tree823084e2c74015f38afca4ce8e0807a9548fa84a /src/simpleapdu/SimpleAPDU.java
parent5f0ec2706a9dbb6aa72ea3c7eb798cd83045e867 (diff)
downloadECTester-da1ee8381f2f7eaf1cfcd4941ec9f95287435625.tar.gz
ECTester-da1ee8381f2f7eaf1cfcd4941ec9f95287435625.tar.zst
ECTester-da1ee8381f2f7eaf1cfcd4941ec9f95287435625.zip
Fixed some issues with errors in key generation, and their propagation
Diffstat (limited to 'src/simpleapdu/SimpleAPDU.java')
-rw-r--r--src/simpleapdu/SimpleAPDU.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/simpleapdu/SimpleAPDU.java b/src/simpleapdu/SimpleAPDU.java
index 241ef4c..4f291f0 100644
--- a/src/simpleapdu/SimpleAPDU.java
+++ b/src/simpleapdu/SimpleAPDU.java
@@ -234,7 +234,13 @@ public class SimpleAPDU {
gatherKeyAPDU[GENERATEECKEY_ALG_OFFSET] = keyClass;
setShort(gatherKeyAPDU, GENERATEECKEY_KEYLENGTH_OFFSET, keyLength);
gatherKeyAPDU[GENERATEECKEY_ANOMALOUS_OFFSET] = anomalous ? (byte) 1 : (byte) 0;
+
ResponseAPDU respGather = cardManager.sendAPDU(gatherKeyAPDU);
+ if (respGather.getSW() != ISO7816.SW_NO_ERROR) {
+ systemOutLogger.println(String.format("Card error: %x", respGather.getSW()));
+ keysFile.close();
+ return;
+ }
// Generate new keypair
gatherKeyAPDU[ISO7816.OFFSET_P1] = SimpleECCApplet.P1_GENERATEKEYPAIR;
@@ -245,6 +251,10 @@ public class SimpleAPDU {
respGather = cardManager.sendAPDU(gatherKeyAPDU);
elapsed += System.nanoTime();
+ if (respGather.getSW() != ISO7816.SW_NO_ERROR) {
+ systemOutLogger.println(String.format("Card error: %x", respGather.getSW()));
+ break;
+ }
byte[] data = respGather.getData();
int offset = 0;
String pubKeyW = "";
@@ -274,6 +284,7 @@ public class SimpleAPDU {
if (counter >= amount && amount != 0)
break;
}
+ keysFile.close();
}
}