Skip to content

Commit

Permalink
improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitgamma committed Jul 25, 2022
1 parent 44a77df commit a692b6b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {

dependencies {
classpath 'com.fidesmo:gradle-javacard:0.2.7'
classpath 'com.github.status-im.status-keycard-java:desktop:953c845'
classpath 'com.github.status-im.status-keycard-java:desktop:31f4ab5'
}
}

Expand Down Expand Up @@ -59,7 +59,7 @@ dependencies {
testCompile(files("../jcardsim/jcardsim-3.0.5-SNAPSHOT.jar"))
testCompile('org.web3j:core:2.3.1')
testCompile('org.bitcoinj:bitcoinj-core:0.14.5')
testCompile('com.github.status-im.status-keycard-java:desktop:953c845')
testCompile('com.github.status-im.status-keycard-java:desktop:31f4ab5')
testCompile('org.bouncycastle:bcprov-jdk15on:1.65')
testCompile("org.junit.jupiter:junit-jupiter-api:5.1.1")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.1")
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ repositories {
}

dependencies {
compile 'com.github.status-im.status-keycard-java:desktop:953c845'
compile 'com.github.status-im.status-keycard-java:desktop:31f4ab5'
}
17 changes: 15 additions & 2 deletions src/test/java/im/status/keycard/KeycardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,26 @@ void selectTest() throws Exception {
@Test
@DisplayName("IDENT command")
void identTest() throws Exception {
APDUResponse response = cmdSet.identifyCard(new byte[33]);
assertEquals(0x6a80, response.getSw());

byte[] challenge = new byte[32];
Random random = new Random();
byte[] expectedCaPub = ((ECPublicKey) caKeyPair.getPublic()).getQ().getEncoded(true);


random.nextBytes(challenge);
APDUResponse response = cmdSet.identifyCard(challenge);
response = cmdSet.identifyCard(challenge);
assertEquals(0x9000, response.getSw());
byte[] caPub = Certificate.verifyIdentity(challenge, response.getData());
byte[] expectedCaPub = ((ECPublicKey) caKeyPair.getPublic()).getQ().getEncoded(true);
assertArrayEquals(expectedCaPub, caPub);

cmdSet.autoOpenSecureChannel();

random.nextBytes(challenge);
response = cmdSet.identifyCard(challenge);
assertEquals(0x9000, response.getSw());
caPub = Certificate.verifyIdentity(challenge, response.getData());
assertArrayEquals(expectedCaPub, caPub);
}

Expand Down

0 comments on commit a692b6b

Please sign in to comment.