mirror of
https://github.com/status-im/status-keycard.git
synced 2025-03-03 22:30:36 +00:00
fix secure channel cases
This commit is contained in:
parent
355ee91d2c
commit
77d0ee8c58
@ -1224,9 +1224,6 @@ public class KeycardApplet extends Applet {
|
|||||||
makeCurrent = true;
|
makeCurrent = true;
|
||||||
break;
|
break;
|
||||||
case SIGN_P1_PINLESS:
|
case SIGN_P1_PINLESS:
|
||||||
if (pinlessPathLen == 0) {
|
|
||||||
ISOException.throwIt(SW_REFERENCED_DATA_NOT_FOUND);
|
|
||||||
}
|
|
||||||
usePinless = true;
|
usePinless = true;
|
||||||
signingKey = pinlessPrivateKey;
|
signingKey = pinlessPrivateKey;
|
||||||
outputKey = pinlessPublicKey;
|
outputKey = pinlessPublicKey;
|
||||||
@ -1244,6 +1241,10 @@ public class KeycardApplet extends Applet {
|
|||||||
len = secureChannel.preprocessAPDU(apduBuffer);
|
len = secureChannel.preprocessAPDU(apduBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (usePinless && pinlessPathLen == 0) {
|
||||||
|
ISOException.throwIt(SW_REFERENCED_DATA_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
if (!((pin.isValidated() || usePinless || isPinless()) && privateKey.isInitialized())) {
|
if (!((pin.isValidated() || usePinless || isPinless()) && privateKey.isInitialized())) {
|
||||||
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
|
ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
|
||||||
}
|
}
|
||||||
@ -1284,7 +1285,11 @@ public class KeycardApplet extends Applet {
|
|||||||
apduBuffer[(short)(SecureChannel.SC_OUT_OFFSET + 1)] = (byte) 0x81;
|
apduBuffer[(short)(SecureChannel.SC_OUT_OFFSET + 1)] = (byte) 0x81;
|
||||||
apduBuffer[(short)(SecureChannel.SC_OUT_OFFSET + 2)] = (byte) (outLen - 3);
|
apduBuffer[(short)(SecureChannel.SC_OUT_OFFSET + 2)] = (byte) (outLen - 3);
|
||||||
|
|
||||||
|
if (secureChannel.isOpen()) {
|
||||||
secureChannel.respond(apdu, outLen, ISO7816.SW_NO_ERROR);
|
secureChannel.respond(apdu, outLen, ISO7816.SW_NO_ERROR);
|
||||||
|
} else {
|
||||||
|
apdu.setOutgoingAndSend(SecureChannel.SC_OUT_OFFSET, outLen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1031,7 +1031,6 @@ public class KeycardTest {
|
|||||||
assertEquals(0x9000, response.getSw());
|
assertEquals(0x9000, response.getSw());
|
||||||
|
|
||||||
// No secure channel or PIN auth
|
// No secure channel or PIN auth
|
||||||
reset();
|
|
||||||
response = cmdSet.select();
|
response = cmdSet.select();
|
||||||
assertEquals(0x9000, response.getSw());
|
assertEquals(0x9000, response.getSw());
|
||||||
|
|
||||||
@ -1055,7 +1054,7 @@ public class KeycardTest {
|
|||||||
assertEquals(0x9000, response.getSw());
|
assertEquals(0x9000, response.getSw());
|
||||||
|
|
||||||
response = cmdSet.signPinless(hash);
|
response = cmdSet.signPinless(hash);
|
||||||
assertEquals(0x6985, response.getSw());
|
assertEquals(0x6A88, response.getSw());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifySignResp(byte[] data, APDUResponse response) throws Exception {
|
private void verifySignResp(byte[] data, APDUResponse response) throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user