Skip to content

Commit

Permalink
Merge pull request #247 from subrahmanyaman/javacard_KeyMint_200_mast…
Browse files Browse the repository at this point in the history
…er_with_factory_attestation_T0_fix

Javacard key mint 200 master with factory attestation t0 fix
  • Loading branch information
mdwivedi authored Dec 2, 2022
2 parents 80b5afc + 551e40a commit 5f0088b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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()) {
Expand Down Expand Up @@ -490,7 +491,7 @@ private void processProvisionAttestationKey(APDU apdu) {

private void processProvisionAttestationCertDataCmd(APDU apdu) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,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()) {
Expand Down Expand Up @@ -486,7 +487,7 @@ private void processProvisionAttestationKey(APDU apdu) {

private void processProvisionAttestationCertDataCmd(APDU apdu) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ 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.
Expand All @@ -311,6 +312,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;
Expand Down Expand Up @@ -916,7 +918,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.
Expand Down

0 comments on commit 5f0088b

Please sign in to comment.