Skip to content

Commit

Permalink
Merge pull request #184 from crocs-muni/devel
Browse files Browse the repository at this point in the history
Improvemets, bug fixes and new cards
  • Loading branch information
petrs authored Dec 12, 2018
2 parents 6ebfb02 + 5d15002 commit 42abaaa
Show file tree
Hide file tree
Showing 93 changed files with 40,897 additions and 11,608 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/!!!temp/
/AlgTest_JavaCard/nbproject/private/
/AlgTest_JavaCard/!uploader/
/AlgTest_JClient/nbproject/private/
/AlgTest_Process/nbproject/private/
/AlgTest_JavaCard/build/
Expand Down
2 changes: 2 additions & 0 deletions AlgTest_JClient/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
<!-- Copy newly build jar into test directory for simulator of smart cards-->
<copy file="${basedir}/dist/AlgTestJClient.jar" tofile="${basedir}/test/AlgTestJClient.jar"/>
</target>


</project>
Binary file modified AlgTest_JClient/dist/AlgTestJClient.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/is-native-c.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/is-runtime.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jcardsim-2.2.2-all.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jctasks.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jna-4.1.0.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jna-platform-4.1.0.jar
Binary file not shown.
Binary file added AlgTest_JClient/dist/lib/jna.jar
Binary file not shown.
Binary file added AlgTest_JClient/jcardsim-3.0.5-SNAPSHOT.jar
Binary file not shown.
Binary file added AlgTest_JClient/libs/jcardsim-2.2.1-all.jar
Binary file not shown.
Binary file added AlgTest_JClient/libs/jcardsim-2.2.2-all.jar
Binary file not shown.
Binary file added AlgTest_JClient/libs/jcardsim-3.0.4-SNAPSHOT.jar
Binary file not shown.
Binary file added AlgTest_JClient/libs/jcardsim-3.0.5-SNAPSHOT.jar
Binary file not shown.
107 changes: 107 additions & 0 deletions AlgTest_JClient/nbproject/project.properties.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=AlgTestJClient
application.vendor=petr
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/AlgTestJClient.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.AlgTest-AlgTest_JavaCard=../AlgTest_JavaCard
file.reference.AlgTest_JavaCard-src=../AlgTest_JavaCard/src
file.reference.is-native-c.jar=libs\\JNA\\is-native-c.jar
file.reference.is-runtime.jar=libs\\JNA\\is-runtime.jar
file.reference.jcardsim-2.2.2-all.jar=test\\jcardsim-2.2.2-all.jar
file.reference.jcardsim-3.0.4.jar=jcardsim-3.0.4.jar
file.reference.jctasks.jar=libs\\JNA\\jctasks.jar
file.reference.jna-4.1.0.jar=libs\\JNA\\jna-4.1.0.jar
file.reference.jna-platform-4.1.0.jar=libs\\JNA\\jna-platform-4.1.0.jar
file.reference.jna.jar=libs\\JNA\\jna.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.jcardsim-2.2.2-all.jar}:\
${file.reference.is-native-c.jar}:\
${file.reference.is-runtime.jar}:\
${file.reference.jctasks.jar}:\
${file.reference.jna-4.1.0.jar}:\
${file.reference.jna-platform-4.1.0.jar}:\
${file.reference.jna.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=false
javac.processorpath=\
${javac.classpath}
javac.source=1.7
javac.target=1.7
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.testng.classpath}:\
${libs.JCardSim222.classpath}:\
${file.reference.jcardsim-3.0.4.jar}:\
${file.reference.jcardsim-2.2.2-all.jar}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=algtestjclient.AlgTestJClient
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
src.src.dir=${file.reference.AlgTest_JavaCard-src}
test.src.dir=test
2 changes: 1 addition & 1 deletion AlgTest_JClient/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>AlgTestJClient</name>
<source-roots>
<root id="src.src2.dir"/>
<root id="src.dir"/>
<root id="src.src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
Expand Down
108 changes: 70 additions & 38 deletions AlgTest_JClient/src/algtestjclient/AlgTestJClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ may be distributed under the terms of the GNU General Public License (GPL),
package algtestjclient;

import algtest.JCConsts;
import cardTools.SimulatedCardTerminal;
import java.io.*;
import java.util.List;
import java.util.Scanner;
Expand All @@ -50,15 +51,25 @@ may be distributed under the terms of the GNU General Public License (GPL),
*/
public class AlgTestJClient {
/* Arguments for choosing which AlgTest version to run. */
public static final String ALGTEST_MULTIPERAPDU = "AT_MULTIPERAPDU"; // for 'old' AlgTest
public static final String ALGTEST_SINGLEPERAPDU = "AT_SINGLEPERAPDU"; // for 'New' AlgTest
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.6 (7.12.2018)
* + Added support for jCardSim
* + Added testing of AEAD ciphers
* + added attempt to enable high-power mode for SIM cards
* - remove testing RSA arbitrary exponent (problem with J3H081 card)
* - fixed bugs
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_6 = "1.7.6";

/**
* Version 1.7.5 (17.09.2018)
* - update of preallocated size of RAM (applet updated)
*/
public final static String ALGTEST_JCLIENT_VERSION_1_7_5 = "1.7.5";
//public final static String ALGTEST_JCLIENT_VERSION_1_7_5 = "1.7.5";

/**
* Version 1.7.4 (20.04.2018)
Expand Down Expand Up @@ -128,9 +139,12 @@ public class AlgTestJClient {
/**
* Current version
*/
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_5;
public final static String ALGTEST_JCLIENT_VERSION = ALGTEST_JCLIENT_VERSION_1_7_6;

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;
/**
* @param args the command line arguments
*/
Expand All @@ -147,6 +161,16 @@ public static void main(String[] args) throws IOException, Exception {
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");

if (args.length > 0) {
for (String arg : args) {
if (arg.equals(ALGTEST_USE_SIMULATOR)) {
USE_JCARDSIM = true;
}
}
}

/* fix arguments processing
// If arguments are present.
if(args.length > 0){
if (args[0].equals(ALGTEST_SINGLEPERAPDU)){
Expand All @@ -165,6 +189,7 @@ else if (args[0].equals(ALGTEST_PERFORMANCE)){
}
// If there are no arguments present
else {
*/
CardTerminal selectedTerminal = null;
PerformanceTesting testingPerformance = new PerformanceTesting(m_SystemOutLogger);
m_SystemOutLogger.println("NOTE: JCAlgTest applet (AlgTest.cap) must be already installed on tested card.");
Expand Down Expand Up @@ -222,8 +247,9 @@ else if (args[0].equals(ALGTEST_PERFORMANCE)){
System.err.println("Incorrect parameter!");
break;
}
/* fix arguments processing
}
*/
}

static void performKeyHarvest() throws CardException {
Expand Down Expand Up @@ -332,46 +358,52 @@ static void performKeyHarvest() throws CardException {
}

static CardTerminal selectTargetReader() {
// Test available card - if more present, let user to select one
List<CardTerminal> terminalList = CardMngr.GetReaderList(false);
CardTerminal selectedTerminal = null;
if (terminalList.isEmpty()) {
m_SystemOutLogger.println("ERROR: No suitable reader with card detected. Please check your reader connection");
return null;
// If required, return simulated card (jCardSim), otherwise let user to choose
if (USE_JCARDSIM) {
return new SimulatedCardTerminal();
}
else {
if (terminalList.size() == 1) {
selectedTerminal = terminalList.get(0); // return first and only reader
// Test available card - if more present, let user to select one
List<CardTerminal> terminalList = CardMngr.GetReaderList(false);
CardTerminal selectedTerminal = null;
if (terminalList.isEmpty()) {
m_SystemOutLogger.println("ERROR: No suitable reader with card detected. Please check your reader connection");
return null;
}
else {
int terminalIndex = 1;
// Let user select target terminal
m_SystemOutLogger.println("\nAvailable readers:");
for (CardTerminal terminal : terminalList) {
Card card;
try {
card = terminal.connect("*");
ATR atr = card.getATR();
m_SystemOutLogger.println(String.format("%d : [*] %s - %s", terminalIndex, terminal.getName(), CardMngr.bytesToHex(atr.getBytes())));
terminalIndex++;
} catch (CardNotPresentException ex) {
m_SystemOutLogger.println(String.format("%d : [ ] %s - NO CARD", terminalIndex, terminal.getName()));
terminalIndex++;
} catch (CardException ex) {
Logger.getLogger(AlgTestJClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
m_SystemOutLogger.print("Select index of target reader you like to use [1.." + (terminalIndex - 1) + "]: ");
Scanner sc = new Scanner(System.in);
int answ = sc.nextInt();
m_SystemOutLogger.println(String.format("%d", answ));
answ--; // is starting with 0
// BUGBUG; verify allowed index range
selectedTerminal = terminalList.get(answ);
if (terminalList.size() == 1) {
selectedTerminal = terminalList.get(0); // return first and only reader
}
else {
int terminalIndex = 1;
// Let user select target terminal
m_SystemOutLogger.println("\nAvailable readers:");
for (CardTerminal terminal : terminalList) {
Card card;
try {
card = terminal.connect("*");
ATR atr = card.getATR();
m_SystemOutLogger.println(String.format("%d : [*] %s - %s", terminalIndex, terminal.getName(), CardMngr.bytesToHex(atr.getBytes())));
terminalIndex++;
} catch (CardNotPresentException ex) {
m_SystemOutLogger.println(String.format("%d : [ ] %s - NO CARD", terminalIndex, terminal.getName()));
terminalIndex++;
} catch (CardException ex) {
Logger.getLogger(AlgTestJClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
m_SystemOutLogger.print("Select index of target reader you like to use [1.." + (terminalIndex - 1) + "]: ");
Scanner sc = new Scanner(System.in);
int answ = sc.nextInt();
m_SystemOutLogger.println(String.format("%d", answ));
answ--; // is starting with 0
// BUGBUG; verify allowed index range
selectedTerminal = terminalList.get(answ);
}
}

return selectedTerminal;
}

return selectedTerminal;
}

}
Loading

0 comments on commit 42abaaa

Please sign in to comment.