Skip to content

Commit

Permalink
Merge pull request #231 from crocs-muni/devel
Browse files Browse the repository at this point in the history
add new version 1.8.0
  • Loading branch information
petrs authored Dec 22, 2020
2 parents 21d598e + b084f5a commit e3ba2a4
Show file tree
Hide file tree
Showing 195 changed files with 37,072 additions and 613 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/AlgTest_JavaCard/!uploader/*
/AlgTest_JavaCard/build/*
/AlgTest_JavaCard/nbproject/project.properties

/AlgTest_JavaCard/src222/*
/AlgTest_JavaCard/src304/*
/AlgTest_JavaCard/src305/*

/AlgTest_JClient/nbproject/private/
/AlgTest_JClient/build/*
Expand Down
44 changes: 39 additions & 5 deletions AlgTest_JClient/src/algtestjclient/AlgTestJClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,24 @@ public class AlgTestJClient {
public static final String ALGTEST_USE_SIMULATOR = "JCARDSIM"; // use simulator instead of real card
public static final String ALGTEST_USE_CUSTOM_AID = "AID="; // use custom AID for applet (if default one is changed for some reason)

/**
* Version 1.8.0 (19.12.2020)
* + testing of modular Cipher and Signature .getInstance variants
* + testing of OneShot variants
* + testing of InitializedMessageDigest
*/
public final static String ALGTEST_JCLIENT_VERSION_1_8_0 = "1.8.0";
/**
* Version 1.7.10 (29.11.2020)
* + parsing memory overhead for object allocation
* + added request for sending data to public database
*/
//public final static String ALGTEST_JCLIENT_VERSION_1_7_10 = "1.7.10";
/**
* Version 1.7.9 (22.07.2019)
* - no changes, updating version with card applet
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_9 = "1.7.9";
//public final static String ALGTEST_JCLIENT_VERSION_1_7_9 = "1.7.9";
/**
* Version 1.7.8 (18.05.2019)
* - no changes, updating version with card applet
Expand Down Expand Up @@ -155,26 +168,29 @@ public class AlgTestJClient {
/**
* Current version
*/
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_9;
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_8_0;

public final static int STAT_OK = 0;

// If required to be run with simulator, run as: >java -cp "AlgTestJClient.jar;jcardsim-3.0.5-SNAPSHOT.jar" -noverify algtestjclient.AlgTestJClient JCARDSIM
static boolean USE_JCARDSIM = false;

// Unique start time in milisconds
static long m_appStartTime = 0;

/**
* @param args the command line arguments
*/

static DirtyLogger m_SystemOutLogger = null;
public static void main(String[] args) throws IOException, Exception {
String logFileName = String.format("ALGTEST_log_%d.log", System.currentTimeMillis());
String logFileName = String.format("ALGTEST_log_%s.log", AlgTestJClient.getStartTime());
FileOutputStream systemOutLogger = new FileOutputStream(logFileName);
m_SystemOutLogger = new DirtyLogger(systemOutLogger, true);

m_SystemOutLogger.println("\n----------------------------------------------------------------------- ");
m_SystemOutLogger.println("JCAlgTest " + ALGTEST_JCLIENT_VERSION + " - comprehensive tool for JavaCard smart card testing.");
m_SystemOutLogger.println("Visit jcalgtest.org for results from 60+ cards. CRoCS lab 2007-2017.");
m_SystemOutLogger.println("Visit jcalgtest.org for results from 100+ cards. CRoCS lab 2007-2021.");
m_SystemOutLogger.println("Please check if you use the latest version at\n https://github.com/crocs-muni/JCAlgTest/releases/latest.");

m_SystemOutLogger.println("-----------------------------------------------------------------------\n");
Expand Down Expand Up @@ -229,7 +245,7 @@ else if (args[0].equals(ALGTEST_PERFORMANCE)){
Scanner sc = new Scanner(System.in);
int answ = sc.nextInt();
m_SystemOutLogger.println(String.format("%d", answ));
switch (answ){
switch (answ) {
// In this case, SinglePerApdu version of AlgTest is used.
case 1:
selectedTerminal = selectTargetReader();
Expand Down Expand Up @@ -274,6 +290,24 @@ else if (args[0].equals(ALGTEST_PERFORMANCE)){
/* fix arguments processing
}
*/
printSendRequest();
}

static long getStartTime() {
if (m_appStartTime == 0) {
m_appStartTime = System.currentTimeMillis();
}
return m_appStartTime;
}

static void printSendRequest() {
System.out.println("\n-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
System.out.println("KIND REQUEST: Please consider sending us your results to extend info openly");
System.out.println("available to all JavaCard enthusiasts at http://jcalgtest.org.");
System.out.println("The results are important even if a card of same type is already in database.");
System.out.println("Send *.log and *.csv files from the current directory to <petr@svenda.com>.");
System.out.println("Thank you very much!");
System.out.println("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*");
}

static void performKeyHarvest() throws CardException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String toString()
case AlgPerformanceTest.SW_ALG_INCORECT_REPETITIONS:
return "SW_ALG_INCORECT_REPETITIONS";
default:
return "UNKONWN_ERROR-card_has_return_value_" + Integer.toHexString(reason);
return Utils.ErrorToString(reason);
}
}
}
17 changes: 14 additions & 3 deletions AlgTest_JClient/src/algtestjclient/CardMngr.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ may be distributed under the terms of the GNU General Public License (GPL),
import algtest.TestSettings;
import cardTools.SimulatedCardChannelLocal;
import cardTools.SimulatedCardTerminal;
import cardTools.Util;
import com.licel.jcardsim.io.CAD;
import com.licel.jcardsim.io.JavaxSmartCardInterface;

Expand Down Expand Up @@ -663,7 +664,7 @@ public int GetJCSystemInfo(StringBuilder pValue, FileOutputStream pFile) throws
apdu[OFFSET_CLA] = Consts.CLA_CARD_ALGTEST;
apdu[OFFSET_INS] = Consts.INS_CARD_JCSYSTEM_INFO;
//apdu[OFFSET_P1] = 0x00;
apdu[OFFSET_P1] = AlgSupportTest.RETURN_INSTALL_TIME_RAM_SIZE;
apdu[OFFSET_P1] = AlgSupportTest.RETURN_INSTALL_TIME_MEMORY_SIZE;
apdu[OFFSET_P2] = 0x00;
apdu[OFFSET_LC] = 0x01;
apdu[OFFSET_DATA] = 0x01;
Expand Down Expand Up @@ -695,12 +696,19 @@ public int GetJCSystemInfo(StringBuilder pValue, FileOutputStream pFile) throws
int apduOutBlockSize = -1;
int apduProtocol = -1;
int apduNAD = -1;
if (temp.length > 11) {
if (temp.length > 11) { // info about blocks is available
apduInBlockSize = (temp[11] << 8) + (temp[12] & 0xff);
apduOutBlockSize = (temp[13] << 8) + (temp[14] & 0xff);
apduProtocol = temp[15];
apduNAD = temp[16];
}
if (temp.length > 17) { // more detailed info about memory is available
int offset = 17;
eepromSize = Util.getInt(temp, offset); offset += 4;
// RAM values are unused now, as we already have them and are measured before all allocations
int unused_ramDeselectSize2 = Util.getInt(temp, offset); offset += 4;
int unused_ramResetSize2 = Util.getInt(temp, offset); offset += 4;
}



Expand Down Expand Up @@ -1031,9 +1039,12 @@ public int TestAction(String actionName, byte apdu[], StringBuilder pValue, File
}

public boolean resetApplet(byte cla, byte ins) {
return resetApplet(cla, ins, (byte) 0);
}
public boolean resetApplet(byte cla, byte ins, byte p1) {
try {
m_SystemOutLogger.println("\nFree unused card objects...\n");
byte apdu[] = {cla,ins,0,0};
byte apdu[] = {cla,ins,p1,0};
ResponseAPDU resp = sendAPDU(apdu);
if (resp.getSW() != 0x9000) {
return false;
Expand Down
Loading

0 comments on commit e3ba2a4

Please sign in to comment.