Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
Expand Up@@ -3142,6 +3142,10 @@ private void updateKeyParameters(byte[] ptrArr, short len) {
}

// This command is executed to set the boot parameters.
// releaseAllOperations has to be called on every boot, so
// it is called from inside setBootParams. Later in future if
// setBootParams is removed, then make sure that releaseAllOperations
// is moved to a place where it is called on every boot.
private void processSetBootParamsCmd(APDU apdu) {
receiveIncoming(apdu);
byte[] scratchPad = apdu.getBuffer();
Expand DownExpand Up@@ -3230,6 +3234,9 @@ private void processSetBootParamsCmd(APDU apdu) {
repository.clearComputedHmac();
repository.clearHmacNonce();

//Clear all the operation state.
repository.releaseAllOperations();

// Hmac is cleared, so generate a new Hmac nonce.
seProvider.newRandomNumber(scratchPad, (short) 0, KMRepository.HMAC_SEED_NONCE_SIZE);
repository.initHmacNonce(scratchPad, (short) 0, KMRepository.HMAC_SEED_NONCE_SIZE);
Expand Down
20 changes: 20 additions & 0 deletions Applet/src/com/android/javacard/keymaster/KMRepository.java
Original file line numberDiff line numberDiff line change
Expand Up@@ -256,6 +256,26 @@ public void releaseOperation(KMOperationState op) {
}
}

public void releaseAllOperations() {
short index = 0;
byte[] oprHandleBuf;
while (index < MAX_OPS) {
oprHandleBuf = ((byte[]) ((Object[]) operationStateTable[index])[0]);
if (oprHandleBuf[OPERATION_HANDLE_STATUS_OFFSET] == 1) {
Object[] slot = (Object[]) ((Object[]) operationStateTable[index])[1];
Object[] ops = ((Object[]) slot[1]);
((KMOperation) ops[0]).abort();
JCSystem.beginTransaction();
Util.arrayFillNonAtomic((byte[]) slot[0], (short) 0,
(short) ((byte[]) slot[0]).length, (byte) 0);
Util.arrayFillNonAtomic(oprHandleBuf, (short) 0, (short) oprHandleBuf.length, (byte) 0);
ops[0] = null;
JCSystem.commitTransaction();
}
index++;
}
}

public void initComputedHmac(byte[] key, short start, short len) {
if (len != COMPUTED_HMAC_KEY_SIZE) {
KMException.throwIt(KMError.INVALID_INPUT_LENGTH);
Expand Down