diff --git a/Applet/AndroidSEProvider/src/com/android/javacard/keymaster/KMAndroidSEApplet.java b/Applet/AndroidSEProvider/src/com/android/javacard/keymaster/KMAndroidSEApplet.java index 6c2a5a77..ffeb1409 100644 --- a/Applet/AndroidSEProvider/src/com/android/javacard/keymaster/KMAndroidSEApplet.java +++ b/Applet/AndroidSEProvider/src/com/android/javacard/keymaster/KMAndroidSEApplet.java @@ -98,6 +98,7 @@ public void handleDeviceBooted() { @Override public void process(APDU apdu) { try { + receiveLen[0] = apdu.setIncomingAndReceive(); handleDeviceBooted(); // If this is select applet apdu which is selecting this applet then return if (apdu.isISOInterindustryCLA()) { @@ -411,7 +412,7 @@ private void processProvisionRkpAdditionalCertChain(APDU apdu) { // Store the cbor encoded UdsCerts as it is in the persistent memory so cbor decoding is // required here. byte[] srcBuffer = apdu.getBuffer(); - short recvLen = apdu.setIncomingAndReceive(); + short recvLen = receiveLen[0]; short srcOffset = apdu.getOffsetCdata(); short bufferLength = apdu.getIncomingLength(); short bufferStartOffset = repository.allocReclaimableMemory(bufferLength); diff --git a/Applet/JCardSimProvider/src/com/android/javacard/keymaster/KMJCardSimApplet.java b/Applet/JCardSimProvider/src/com/android/javacard/keymaster/KMJCardSimApplet.java index 29536c25..68542e45 100644 --- a/Applet/JCardSimProvider/src/com/android/javacard/keymaster/KMJCardSimApplet.java +++ b/Applet/JCardSimProvider/src/com/android/javacard/keymaster/KMJCardSimApplet.java @@ -86,6 +86,7 @@ public void handleDeviceBooted() { @Override public void process(APDU apdu) { try { + receiveLen[0] = apdu.setIncomingAndReceive(); handleDeviceBooted(); // If this is select applet apdu which is selecting this applet then return if (apdu.isISOInterindustryCLA()) { @@ -404,7 +405,7 @@ private void processProvisionRkpAdditionalCertChain(APDU apdu) { // Store the cbor encoded UdsCerts as it is in the persistent memory so cbor decoding is // required here. byte[] srcBuffer = apdu.getBuffer(); - short recvLen = apdu.setIncomingAndReceive(); + short recvLen = receiveLen[0]; short srcOffset = apdu.getOffsetCdata(); short bufferLength = apdu.getIncomingLength(); short bufferStartOffset = repository.allocReclaimableMemory(bufferLength); diff --git a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java index 5efdc382..6aa31a0f 100644 --- a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java +++ b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java @@ -302,6 +302,8 @@ public class KMKeymasterApplet extends Applet implements AppletEvent, ExtendedLe protected static short[] tmpVariables; protected static short[] data; protected static byte[] wrappingKey; + protected static short[] receiveLen; + /** * Registers this applet. @@ -317,6 +319,7 @@ protected KMKeymasterApplet(KMSEProvider seImpl) { tmpVariables = JCSystem.makeTransientShortArray(TMP_VARIABLE_ARRAY_SIZE, JCSystem.CLEAR_ON_DESELECT); wrappingKey = JCSystem.makeTransientByteArray((short)(WRAPPING_KEY_SIZE+1), JCSystem.CLEAR_ON_RESET); + receiveLen = JCSystem.makeTransientShortArray((short) 1, JCSystem.CLEAR_ON_RESET); resetWrappingKey(); opTable = new KMOperationState[MAX_OPERATIONS_COUNT]; short index = 0; @@ -906,7 +909,7 @@ public void sendOutgoing(APDU apdu, KMAttestationCert cert, short certStart, sho */ public static short receiveIncoming(APDU apdu, short reqExp) { byte[] srcBuffer = apdu.getBuffer(); - short recvLen = apdu.setIncomingAndReceive(); + short recvLen = receiveLen[0]; short srcOffset = apdu.getOffsetCdata(); // TODO add logic to handle the extended length buffer. In this case the memory can be reused // from extended buffer.