Skip to content

Commit

Permalink
Merge pull request #162 from crocs-muni/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
petrs authored Apr 22, 2018
2 parents 20e8207 + c25ac09 commit 9c318c6
Show file tree
Hide file tree
Showing 10 changed files with 35,982 additions and 1,333 deletions.
Binary file modified AlgTest_JClient/dist/AlgTestJClient.jar
Binary file not shown.
10 changes: 8 additions & 2 deletions AlgTest_JClient/src/algtestjclient/AlgTestJClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ public class AlgTestJClient {
public static final String ALGTEST_SINGLEPERAPDU = "AT_SINGLEPERAPDU"; // for 'New' AlgTest
public static final String ALGTEST_PERFORMANCE = "AT_PERFORMANCE"; // for performance testing

/**
* Version 1.7.4 (20.04.2018)
* + fixed occasional freeze on some cards when testing MessageDigest performance
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_4 = "1.7.4";

/**
* Version 1.7.3 (10.06.2017)
* + added new constants from JC3.0.5
* - fixed bug with incorrect testing of KeyAgreement
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_3 = "1.7.3";
//public final static String ALGTEST_JCLIENT_VERSION_1_7_3 = "1.7.3";

/**
* Version 1.7.2 (06.05.2017)
Expand Down Expand Up @@ -115,7 +121,7 @@ public class AlgTestJClient {
/**
* Current version
*/
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_3;
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_4;

public final static int STAT_OK = 0;
/**
Expand Down
8 changes: 4 additions & 4 deletions AlgTest_JClient/src/algtestjclient/PerformanceTesting.java
Original file line number Diff line number Diff line change
Expand Up @@ -1190,12 +1190,12 @@ public void testMessageDigest(byte alg, String info, short numRepeatWholeOperati

if (!m_bTestVariableData) {
// Ordinary test of all available methods
testSet.algorithmMethod = JCConsts.MessageDigest_update;
this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_update()");
testSet.algorithmMethod = JCConsts.MessageDigest_doFinal;
this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_doFinal()");
double doFinalTime = this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_doFinal()");
testSet.algorithmMethod = JCConsts.MessageDigest_update;
this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_update()", doFinalTime);
testSet.algorithmMethod = JCConsts.MessageDigest_reset;
this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_reset()");
this.perftest_measure(Consts.CLA_CARD_ALGTEST, Consts.INS_PREPARE_TEST_CLASS_MESSAGEDIGEST, Consts.INS_PERF_TEST_CLASS_MESSAGEDIGEST, testSet, info + " MessageDigest_reset()", doFinalTime);
}
else {
// Test of speed dependant on data length
Expand Down
Binary file added AlgTest_JavaCard/AlgTest_v1.7.4_jc222.cap
Binary file not shown.
12 changes: 8 additions & 4 deletions AlgTest_JavaCard/src/AlgTest/AlgPerformanceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1206,17 +1206,21 @@ void perftest_class_MessageDigest(APDU apdu) {
m_testSettings.parse(apdu);
short repeats = (short) (m_testSettings.numRepeatWholeOperation * m_testSettings.numRepeatSubOperation);
short chunkDataLen = (short) (m_testSettings.dataLength1 / m_testSettings.numRepeatSubOperation);

m_digest.reset();

switch (m_testSettings.algorithmMethod) {
case JCConsts.MessageDigest_update:
for (short i = 0; i < repeats; i++) { m_digest.update(m_ram1, (short) 0, chunkDataLen); }
for (short i = 0; i < repeats; i++) {
m_digest.update(m_ram1, (short) 0, chunkDataLen);
m_digest.reset(); // NOTE: added because some cards freeze after many update() then doFinal() call; time substraction needed
}
break;
case JCConsts.MessageDigest_doFinal:
for (short i = 0; i < repeats; i++) { m_digest.doFinal(m_ram1, (short) 0, chunkDataLen, m_ram1, chunkDataLen); }
for (short i = 0; i < repeats; i++) { m_digest.doFinal(m_ram1, (short) 0, chunkDataLen, m_ram2, (short) 0); }
break;
case JCConsts.MessageDigest_reset:
for (short i = 0; i < m_testSettings.numRepeatWholeOperation; i++) {
m_digest.doFinal(m_ram1, (short) 0, chunkDataLen, m_ram1, chunkDataLen); // NOTE: time substraction needed
m_digest.doFinal(m_ram1, (short) 0, chunkDataLen, m_ram2, (short) 0); // NOTE: time substraction needed
m_digest.reset();
}
break;
Expand Down
10 changes: 8 additions & 2 deletions AlgTest_JavaCard/src/AlgTest/JCAlgTestApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ may be distributed under the terms of the GNU General Public License (GPL),
public class JCAlgTestApplet extends javacard.framework.Applet
{
// NOTE: when incrementing version, don't forget to update ALGTEST_JAVACARD_VERSION_CURRENT value
/**
* Version 1.7.4 (20.04.2018) + fixed occasional freeze on some cards when
* testing MessageDigest performance
*/
final static byte ALGTEST_JAVACARD_VERSION_1_7_4[] = {(byte) 0x31, (byte) 0x2e, (byte) 0x37, (byte) 0x2e, (byte) 0x34};

/**
* Version 1.7.3 (10.06.2017) + fixed issue with incorrect test for KeyAgreement support
*/
final static byte ALGTEST_JAVACARD_VERSION_1_7_3[] = {(byte) 0x31, (byte) 0x2e, (byte) 0x37, (byte) 0x2e, (byte) 0x33};
//final static byte ALGTEST_JAVACARD_VERSION_1_7_3[] = {(byte) 0x31, (byte) 0x2e, (byte) 0x37, (byte) 0x2e, (byte) 0x33};
/**
* Version 1.7.2 (06.05.2017)
* + better support for RSA key collection
Expand Down Expand Up @@ -141,7 +147,7 @@ public class JCAlgTestApplet extends javacard.framework.Applet
*/
//final static byte ALGTEST_JAVACARD_VERSION_1_0[] = {(byte) 0x31, (byte) 0x2e, (byte) 0x30};

byte ALGTEST_JAVACARD_VERSION_CURRENT[] = ALGTEST_JAVACARD_VERSION_1_7_3;
byte ALGTEST_JAVACARD_VERSION_CURRENT[] = ALGTEST_JAVACARD_VERSION_1_7_4;
// lower byte of exception is value as defined in JCSDK/api_classic/constant-values.htm
final static short SW_Exception = (short) 0xff01;
final static short SW_ArrayIndexOutOfBoundsException = (short) 0xff02;
Expand Down
Binary file added AlgTest_dist_1.7.4.zip
Binary file not shown.
Loading

0 comments on commit 9c318c6

Please sign in to comment.