This commit is contained in:
Michele Balistreri 2019-05-15 11:49:46 +02:00
parent 3e49fe9626
commit ac3c24852f
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
2 changed files with 11 additions and 0 deletions

View File

@ -542,6 +542,10 @@ public class KeycardApplet extends Applet {
byte[] apduBuffer = apdu.getBuffer();
byte len = (byte) secureChannel.preprocessAPDU(apduBuffer);
if (!(len == PIN_LENGTH && allDigits(apduBuffer, ISO7816.OFFSET_CDATA, len))) {
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
}
if (!pin.check(apduBuffer, ISO7816.OFFSET_CDATA, len)) {
ISOException.throwIt((short)((short) 0x63c0 | (short) pin.getTriesRemaining()));
}

View File

@ -513,6 +513,13 @@ public class KeycardTest {
cmdSet.autoOpenSecureChannel();
// Wrong format
response = cmdSet.verifyPIN("12345");
assertEquals(0x6a80, response.getSw());
response = cmdSet.verifyPIN("12345a");
assertEquals(0x6a80, response.getSw());
// Wrong PIN
response = cmdSet.verifyPIN("123456");
assertEquals(0x63C2, response.getSw());