Skip to content

Commit 4a99be9

Browse files
committed
Include maxMessageSize as applicable
1 parent f76cbbc commit 4a99be9

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5429,8 +5429,10 @@ private void sendAuthInfo(APDU apdu) {
54295429

54305430
short offset = 0;
54315431

5432+
boolean includeMaxMsgSize = bufferMem.length != 1024;
5433+
54325434
buffer[offset++] = FIDOConstants.CTAP2_OK;
5433-
buffer[offset++] = (byte) 0xAF; // Map - fifteen keys
5435+
buffer[offset++] = (byte) (includeMaxMsgSize ? 0xB1 : 0xB0); // Map - sixteen or seventeen keys
54345436
buffer[offset++] = 0x01; // map key: versions
54355437

54365438
if (alwaysUv || attestationData == null || filledAttestationData < attestationData.length) {
@@ -5484,6 +5486,13 @@ private void sendAuthInfo(APDU apdu) {
54845486
buffer, offset, (short) CannedCBOR.MAKE_CRED_UV_NOT_REQD.length);
54855487
buffer[offset++] = (byte)(LOW_SECURITY_MAXIMUM_COMPLIANCE && !alwaysUv ? 0xF5 : 0xF4); // makeCredUvNotRequired = true or false
54865488

5489+
if (includeMaxMsgSize) {
5490+
buffer[offset++] = 0x05; // map key: maxMsgSize
5491+
buffer[offset++] = 0x19; // two-byte integer
5492+
Util.setShort(buffer, offset, (short) bufferMem.length);
5493+
offset += 2;
5494+
}
5495+
54875496
buffer[offset++] = 0x06; // map key: pinProtocols
54885497
buffer[offset++] = (byte) 0x82; // array: two items
54895498
buffer[offset++] = 0x01; // pin protocol version 1
@@ -5492,17 +5501,17 @@ private void sendAuthInfo(APDU apdu) {
54925501
buffer[offset++] = 0x07; // map key: maxCredentialCountInList
54935502
buffer[offset++] = 0x0A; // ten
54945503

5495-
buffer[offset++] = 0x08; // map key: maxCredentialIdLength
5496-
offset = encodeIntTo(buffer, offset, (byte) CREDENTIAL_ID_LEN);
54975504
final short amountInApduBuf = offset;
5498-
54995505
if (!longResponse) {
55005506
// We're going to have too much for one 256-byte buffer
55015507
// So let's split into two halves, one directly APDU-written and one saved
55025508
buffer = bufferMem;
55035509
offset = 0;
55045510
}
55055511

5512+
buffer[offset++] = 0x08; // map key: maxCredentialIdLength
5513+
offset = encodeIntTo(buffer, offset, (byte) CREDENTIAL_ID_LEN);
5514+
55065515
buffer[offset++] = 0x0A; // map key: algorithms
55075516
offset = Util.arrayCopyNonAtomic(CannedCBOR.ES256_ALG_TYPE, (short) 0,
55085517
buffer, offset, (short) CannedCBOR.ES256_ALG_TYPE.length);
@@ -5527,7 +5536,7 @@ private void sendAuthInfo(APDU apdu) {
55275536
buffer[offset++] = 0x10; // map key: maxRPIDsForSetMinPinLength
55285537
offset = encodeIntTo(buffer, offset, MAX_RP_IDS_MIN_PIN_LENGTH);
55295538

5530-
/*buffer[offset++] = 0x12; // map key: uvModality
5539+
buffer[offset++] = 0x12; // map key: uvModality
55315540
buffer[offset++] = 0x19; // two-byte integer
55325541
offset = Util.setShort(buffer, offset, (short) 0x0200); // uvModality "none"*/
55335542

@@ -6703,6 +6712,8 @@ private FIDO2Applet(byte[] array, short offset, byte length) {
67036712
FLASH_SCRATCH_SIZE = Util.getShort(array, offset);
67046713
offset += 2;
67056714
break;
6715+
default:
6716+
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
67066717
}
67076718
}
67086719
}

0 commit comments

Comments
 (0)