better SELECT response

This commit is contained in:
Michele Balistreri 2019-06-10 15:11:16 +02:00
parent 5e68adb79e
commit 576cabb04b
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
4 changed files with 20 additions and 7 deletions

View File

@ -57,7 +57,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:8b73b6c')
testCompile('com.github.status-im.status-keycard-java:desktop:49ad217')
testCompile('org.bouncycastle:bcprov-jdk15on:1.60')
testCompile("org.junit.jupiter:junit-jupiter-api:5.1.1")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.1")

View File

@ -4,5 +4,5 @@ repositories {
}
dependencies {
compile 'com.github.status-im.status-keycard-java:desktop:8b73b6c'
compile 'com.github.status-im.status-keycard-java:desktop:49ad217'
}

View File

@ -84,10 +84,23 @@ public class CashApplet extends Applet {
private void selectApplet(APDU apdu) {
byte[] apduBuffer = apdu.getBuffer();
apduBuffer[0] = KeycardApplet.TLV_PUB_KEY;
apduBuffer[1] = (byte) publicKey.getW(apduBuffer, (short) 2);
short off = 0;
apdu.setOutgoingAndSend((short) 0, (short)(apduBuffer[1] + 2));
apduBuffer[off++] = KeycardApplet.TLV_APPLICATION_INFO_TEMPLATE;
short lenoff = off++;
apduBuffer[off++] = KeycardApplet.TLV_PUB_KEY;
short keyLength = publicKey.getW(apduBuffer, (short) (off + 1));
apduBuffer[off++] = (byte) keyLength;
off += keyLength;
apduBuffer[off++] = KeycardApplet.TLV_INT;
apduBuffer[off++] = 2;
Util.setShort(apduBuffer, off, KeycardApplet.APPLICATION_VERSION);
off += 2;
apduBuffer[lenoff] = (byte)(off - lenoff - 1);
apdu.setOutgoingAndSend((short) 0, off);
}
private void sign(APDU apdu) {

View File

@ -1446,8 +1446,8 @@ public class KeycardTest {
APDUResponse response = cashCmdSet.select();
assertEquals(0x9000, response.getSw());
ApplicationInfo info = new ApplicationInfo(response.getData());
assertFalse(info.isInitializedCard());
CashApplicationInfo info = new CashApplicationInfo(response.getData());
assertTrue(info.getAppVersion() > 0);
byte[] data = "some data to be hashed".getBytes();
byte[] hash = sha256(data);