Skip to content

Commit 8a7e18a

Browse files
committed
Force use of FIDO AID
Some cards apparently don't support checking their own applet ID...
1 parent bf1f2fe commit 8a7e18a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/java/us/q3q/fido2/FIDO2Applet.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ public final class FIDO2Applet extends Applet implements ExtendedLength {
1515
* The version of this applet in use
1616
*/
1717
private static final byte FIRMWARE_VERSION = 0x04;
18+
19+
/**
20+
* The AID to which this applet should respond (ignoring any other AIDs sent to it)
21+
*/
22+
private static final byte[] AID = {
23+
(byte) 0xA0, 0x00, 0x00, 0x06, 0x47,
24+
0x2F, 0x00, 0x01
25+
};
26+
1827
// Configurable parameters
1928
/**
2029
* If set, use low-security keys for everything, to fully comply with the FIDO standards without alwaysUv
@@ -4320,7 +4329,8 @@ private boolean streamOutgoingContinuation(APDU apdu, byte[] apduBytes, boolean
43204329
private void handleAppletSelect(APDU apdu) {
43214330
apdu.setIncomingAndReceive();
43224331

4323-
if (!JCSystem.getAID().equals(apdu.getBuffer(), apdu.getOffsetCdata(), (byte) apdu.getIncomingLength())) {
4332+
if (Util.arrayCompare(AID, (short) 0,
4333+
apdu.getBuffer(), apdu.getOffsetCdata(), apdu.getIncomingLength()) != 0) {
43244334
throwException(ISO7816.SW_FILE_NOT_FOUND);
43254335
}
43264336

src/test/java/us/q3q/fido2/AppletBasicTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
public class AppletBasicTest {
2323

2424
CardSimulator simulator;
25-
AID appletAID = AIDUtil.create("F000000001");
25+
AID appletAID = AIDUtil.create("A0000006472F0001");
2626
AID randoAID = AIDUtil.create("F100900001");
2727

2828
@BeforeEach

0 commit comments

Comments
 (0)