Skip to content

Commit

Permalink
Merge pull request #195 from crocs-muni/devel
Browse files Browse the repository at this point in the history
Devel, v1.7.8
  • Loading branch information
petrs authored May 18, 2019
2 parents 27152b3 + d448cef commit 1727952
Show file tree
Hide file tree
Showing 14 changed files with 27,808 additions and 197 deletions.
Binary file removed AlgTest_JClient/dist/lib/jcardsim-2.2.2-all.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jcardsim-3.0.5.5.jar
Binary file not shown.
Binary file added AlgTest_JClient/libs/jcardsim-3.0.5.5.jar
Binary file not shown.
22 changes: 17 additions & 5 deletions AlgTest_JClient/src/algtestjclient/AlgTestJClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
in the documentation and/or other associated materials;
3. the copyright holder's name is not used to endorse products
built using this software without specific written permission.hi
built using this software without specific written permission.
ALTERNATIVELY, provided that this notice is retained in full, this product
may be distributed under the terms of the GNU General Public License (GPL),
Expand Down Expand Up @@ -55,11 +55,16 @@ public class AlgTestJClient {
public static final String ALGTEST_PERFORMANCE = "AT_PERFORMANCE"; // for performance testing
public static final String ALGTEST_USE_SIMULATOR = "JCARDSIM"; // use simulator instead of real card

/**
* Version 1.7.8 (18.05.2019)
* - no changes, updating version with card applet
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_8 = "1.7.8";
/**
* Version 1.7.7 (17.04.2019)
* - removed testing for high-power mode for SIM cards as some cards stop responding till reset
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_7 = "1.7.7";
//public final static String ALGTEST_JCLIENT_VERSION_1_7_7 = "1.7.7";
/**
* Version 1.7.6 (7.12.2018)
* + Added support for jCardSim
Expand All @@ -68,7 +73,7 @@ public class AlgTestJClient {
* - remove testing RSA arbitrary exponent (problem with J3H081 card)
* - fixed bugs
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_6 = "1.7.6";
//public final static String ALGTEST_JCLIENT_VERSION_1_7_6 = "1.7.6";

/**
* Version 1.7.5 (17.09.2018)
Expand Down Expand Up @@ -144,7 +149,7 @@ public class AlgTestJClient {
/**
* Current version
*/
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_7;
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_8;

public final static int STAT_OK = 0;

Expand Down Expand Up @@ -174,7 +179,14 @@ public static void main(String[] args) throws IOException, Exception {
}
}
}

/*
CardTerminal selectedTerminalDebug = null;
PerformanceTesting testingPerformanceDebug = new PerformanceTesting(m_SystemOutLogger);
selectedTerminalDebug = selectTargetReader();
if (selectedTerminalDebug != null) {
testingPerformanceDebug.testDebug(args, selectedTerminalDebug);
}
/**/
/* fix arguments processing
// If arguments are present.
if(args.length > 0){
Expand Down
9 changes: 5 additions & 4 deletions AlgTest_JClient/src/algtestjclient/CardMngr.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,11 @@ public ResponseAPDU sendAPDU(byte apdu[]) throws Exception {
m_SystemOutLogger.println(commandAPDU.toString());

m_SystemOutLogger.println(bytesToHex(commandAPDU.getBytes()));

long elapsedCard = -System.currentTimeMillis();
responseAPDU = m_channel.transmit(commandAPDU);

m_SystemOutLogger.println(responseAPDU.toString());
elapsedCard += System.currentTimeMillis();

m_SystemOutLogger.println(String.format("%s, elapsed=%d ms", responseAPDU.toString(), elapsedCard));
m_SystemOutLogger.println(bytesToHex(responseAPDU.getBytes()));

if (responseAPDU.getSW1() == (byte) 0x61) {
Expand Down Expand Up @@ -742,7 +743,7 @@ public static int intCode(short code) {
// Functions for CPLC taken and modified from https://github.com/martinpaljak/GlobalPlatformPro
private static final byte CLA_GP = (byte) 0x80;
private static final byte ISO7816_INS_GET_DATA = (byte) 0xCA;
private static final byte[] SELECT_CM = {(byte) 0x00, (byte) 0xa4, (byte) 0x04, (byte) 0x00};
private static final byte[] SELECT_CM = {(byte) 0x00, (byte) 0xa4, (byte) 0x04, (byte) 0x00, (byte) 0x00};
private static final byte[] FETCH_GP_CPLC_APDU = {CLA_GP, ISO7816_INS_GET_DATA, (byte) 0x9F, (byte) 0x7F, (byte) 0x00};
private static final byte[] FETCH_ISO_CPLC_APDU = {ISO7816.CLA_ISO7816, ISO7816_INS_GET_DATA, (byte) 0x9F, (byte) 0x7F, (byte) 0x00};
private static final byte[] FETCH_GP_CARDDATA_APDU = {CLA_GP, ISO7816_INS_GET_DATA, (byte) 0x00, (byte) 0x66, (byte) 0x00};
Expand Down
64 changes: 63 additions & 1 deletion AlgTest_JClient/src/algtestjclient/PerformanceTesting.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,68 @@ public void testPerformanceFingerprint(String[] args, CardTerminal selectedTermi
finalizeMeasurement();
}

/**
* Calls methods testing card performance limited to fingerprinting
* functions.
*
* @param args
* @param selectedTerminal
* @throws IOException
* @throws Exception
*/
public void testDebug(String[] args, CardTerminal selectedTerminal) throws IOException, Exception {
Scanner sc = new Scanner(System.in);

// Fingeprint wants to test only main operation speed => variable data option with 256B only
m_bTestVariableData = true;
m_testDataLengths.clear();
m_testDataLengths.add(256);

m_bTestSymmetricAlgs = true;
m_bTestAsymmetricAlgs = true;

m_cardName = "debugcard";

// Try to open and load list of already measured algorithms (if provided)
// NOTE: measure always full: LoadAlreadyMeasuredAlgs(m_cardName);
String testInfo = m_cardName + "___";
testInfo += "_DEBUG_";
testInfo += System.currentTimeMillis() + "_"; // add unique time counter

m_elapsedTimeWholeTest = -System.currentTimeMillis();
// Connect to card
this.m_perfResultsFile = m_cardManager.establishConnection(m_cardName, testInfo, selectedTerminal);
m_cardATR = m_cardManager.getATR();

short numRepeatWholeMeasurement = (short) 1;
short numRepeatWholeOperation = (short) 1;

// Debug exception ff01 during preparation - FIXED
//testCipherWithKeyClass(JCConsts.KeyPair_ALG_RSA_CRT, JCConsts.KeyBuilder_TYPE_RSA_PUBLIC, JCConsts.KeyBuilder_LENGTH_RSA_512, JCConsts.Cipher_ALG_RSA_ISO14888, "TYPE_RSA_CRT_PUBLIC LENGTH_RSA_512 ALG_RSA_ISO14888", JCConsts.Cipher_MODE_ENCRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
//testCipherWithKeyClass(JCConsts.KeyPair_ALG_RSA_CRT, JCConsts.KeyBuilder_TYPE_RSA_PUBLIC, JCConsts.KeyBuilder_LENGTH_RSA_512, JCConsts.Cipher_ALG_RSA_PKCS1, "TYPE_RSA_CRT_PUBLIC LENGTH_RSA_512 ALG_RSA_PKCS1", JCConsts.Cipher_MODE_ENCRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);

/*
// Debug problem on Taysis card
// 1024b OK
testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_1024, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_1024 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
// 1984b fails during use UNKONWN_ERROR-card_has_return_value_6f00
testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_1984, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_1984 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
// 2048b and longer fails with preparation 01 90 00<< ILLEGAL_VALUE
testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_2048, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_2048 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
//testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_2048, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_2048 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
//testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_4096, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_4096 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
//testCipher(JCConsts.KeyBuilder_TYPE_RSA_CRT_PRIVATE, JCConsts.KeyBuilder_LENGTH_RSA_4096, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PRIVATE LENGTH_RSA_4096 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_DECRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
*/

// Debug 0xff01 error when switching from 1.6.0 to 1.7.0
testCipherWithKeyClass(JCConsts.KeyPair_ALG_RSA_CRT, JCConsts.KeyBuilder_TYPE_RSA_PUBLIC, JCConsts.KeyBuilder_LENGTH_RSA_1024, JCConsts.Cipher_ALG_RSA_NOPAD, "TYPE_RSA_CRT_PUBLIC LENGTH_RSA_1024 ALG_RSA_NOPAD", JCConsts.Cipher_MODE_ENCRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);
//testCipherWithKeyClass(JCConsts.KeyPair_ALG_RSA_CRT, JCConsts.KeyBuilder_TYPE_RSA_PUBLIC, JCConsts.KeyBuilder_LENGTH_RSA_1024, JCConsts.Cipher_ALG_RSA_PKCS1, "TYPE_RSA_CRT_PUBLIC LENGTH_RSA_1024 ALG_RSA_PKCS1", JCConsts.Cipher_MODE_ENCRYPT, numRepeatWholeOperation, numRepeatWholeMeasurement);

finalizeMeasurement();
}



/**
* Calls methods testing card performance on ECC operations.
*
Expand Down Expand Up @@ -385,7 +447,7 @@ void finalizeMeasurement() throws IOException {
}

void LoadAlreadyMeasuredAlgs(String cardName, String testType) {
String filePath = cardName + testType + "_already_measured.list";
String filePath = testType + "_already_measured.list";
String filePathOld = filePath + ".old";
File f = new File(filePath);
File fOld = new File(filePathOld);
Expand Down
Binary file modified AlgTest_JavaCard/!uploader/AlgTest_222.cap
Binary file not shown.
Binary file added AlgTest_JavaCard/AlgTest_v1.7.8_jc222.cap
Binary file not shown.
Loading

0 comments on commit 1727952

Please sign in to comment.