Skip to content

Commit 14fcd6a

Browse files
committed
More memory savings
1 parent aaebb0c commit 14fcd6a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4022,7 +4022,7 @@ private void u2FAuthenticate(APDU apdu, byte p1) {
40224022
throwException(ISO7816.SW_WRONG_DATA);
40234023
}
40244024

4025-
final short scratchCredHandle = bufferManager.allocate(apdu, CREDENTIAL_ID_LEN, BufferManager.NOT_APDU_BUFFER);
4025+
final short scratchCredHandle = bufferManager.allocate(apdu, CREDENTIAL_PAYLOAD_LEN, BufferManager.NOT_APDU_BUFFER);
40264026
final short scratchCredOffset = bufferManager.getOffsetForHandle(scratchCredHandle);
40274027
final byte[] scratchCredBuffer = bufferManager.getBufferForHandle(apdu, scratchCredHandle);
40284028

@@ -4797,7 +4797,7 @@ private void handleUserUpdate(APDU apdu, byte[] buffer, short readOffset, short
47974797
// Matching cred.
47984798
// We need to extract the credential to check that our PIN token WOULD have permission
47994799
if (permissionsRpId[0] != 0x00) {
4800-
short scratchExtractedCredHandle = bufferManager.allocate(apdu, CREDENTIAL_ID_LEN, BufferManager.ANYWHERE);
4800+
short scratchExtractedCredHandle = bufferManager.allocate(apdu, CREDENTIAL_PAYLOAD_LEN, BufferManager.ANYWHERE);
48014801
short scratchExtractedCredOffset = bufferManager.getOffsetForHandle(scratchExtractedCredHandle);
48024802
byte[] scratchExtractedCredBuffer = bufferManager.getBufferForHandle(apdu, scratchExtractedCredHandle);
48034803
if (!checkCredential(
@@ -4808,7 +4808,7 @@ private void handleUserUpdate(APDU apdu, byte[] buffer, short readOffset, short
48084808
// permissions RP ID in use, but doesn't match RP of this credential
48094809
sendErrorByte(apdu, FIDOConstants.CTAP2_ERR_PIN_AUTH_INVALID);
48104810
}
4811-
bufferManager.release(apdu, scratchExtractedCredHandle, CREDENTIAL_ID_LEN);
4811+
bufferManager.release(apdu, scratchExtractedCredHandle, CREDENTIAL_PAYLOAD_LEN);
48124812
}
48134813

48144814
// If we're here, it's time to update the user info for the stored cred
@@ -4908,8 +4908,7 @@ private void handleDeleteCred(APDU apdu, byte[] buffer, short readOffset, short
49084908
// of the RP for iteration purposes
49094909
short rpHavingSameRP = -1;
49104910

4911-
// Unpack the other cred into the upper half of the output buffer, which we're not using
4912-
short secondCredHandle = bufferManager.allocate(apdu, CREDENTIAL_ID_LEN, BufferManager.NOT_LOWER_APDU);
4911+
short secondCredHandle = bufferManager.allocate(apdu, CREDENTIAL_PAYLOAD_LEN, BufferManager.NOT_LOWER_APDU);
49134912
short secondCredIdx = bufferManager.getOffsetForHandle(secondCredHandle);
49144913
byte[] secondCredBuffer = bufferManager.getBufferForHandle(apdu, secondCredHandle);
49154914

@@ -4931,7 +4930,7 @@ private void handleDeleteCred(APDU apdu, byte[] buffer, short readOffset, short
49314930
}
49324931
}
49334932

4934-
bufferManager.release(apdu, secondCredHandle, CREDENTIAL_ID_LEN);
4933+
bufferManager.release(apdu, secondCredHandle, CREDENTIAL_PAYLOAD_LEN);
49354934

49364935
JCSystem.beginTransaction();
49374936
boolean ok = false;

0 commit comments

Comments
 (0)