better SELECT response
This commit is contained in:
parent
5e68adb79e
commit
576cabb04b
|
@ -57,7 +57,7 @@ dependencies {
|
||||||
testCompile(files("../jcardsim/jcardsim-3.0.5-SNAPSHOT.jar"))
|
testCompile(files("../jcardsim/jcardsim-3.0.5-SNAPSHOT.jar"))
|
||||||
testCompile('org.web3j:core:2.3.1')
|
testCompile('org.web3j:core:2.3.1')
|
||||||
testCompile('org.bitcoinj:bitcoinj-core:0.14.5')
|
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.bouncycastle:bcprov-jdk15on:1.60')
|
||||||
testCompile("org.junit.jupiter:junit-jupiter-api:5.1.1")
|
testCompile("org.junit.jupiter:junit-jupiter-api:5.1.1")
|
||||||
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.1")
|
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.1")
|
||||||
|
|
|
@ -4,5 +4,5 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.github.status-im.status-keycard-java:desktop:8b73b6c'
|
compile 'com.github.status-im.status-keycard-java:desktop:49ad217'
|
||||||
}
|
}
|
|
@ -84,10 +84,23 @@ public class CashApplet extends Applet {
|
||||||
private void selectApplet(APDU apdu) {
|
private void selectApplet(APDU apdu) {
|
||||||
byte[] apduBuffer = apdu.getBuffer();
|
byte[] apduBuffer = apdu.getBuffer();
|
||||||
|
|
||||||
apduBuffer[0] = KeycardApplet.TLV_PUB_KEY;
|
short off = 0;
|
||||||
apduBuffer[1] = (byte) publicKey.getW(apduBuffer, (short) 2);
|
|
||||||
|
|
||||||
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) {
|
private void sign(APDU apdu) {
|
||||||
|
|
|
@ -1446,8 +1446,8 @@ public class KeycardTest {
|
||||||
APDUResponse response = cashCmdSet.select();
|
APDUResponse response = cashCmdSet.select();
|
||||||
assertEquals(0x9000, response.getSw());
|
assertEquals(0x9000, response.getSw());
|
||||||
|
|
||||||
ApplicationInfo info = new ApplicationInfo(response.getData());
|
CashApplicationInfo info = new CashApplicationInfo(response.getData());
|
||||||
assertFalse(info.isInitializedCard());
|
assertTrue(info.getAppVersion() > 0);
|
||||||
|
|
||||||
byte[] data = "some data to be hashed".getBytes();
|
byte[] data = "some data to be hashed".getBytes();
|
||||||
byte[] hash = sha256(data);
|
byte[] hash = sha256(data);
|
||||||
|
|
Loading…
Reference in New Issue