From 500caa1f074dea0027c6f7fe81414501821e316d Mon Sep 17 00:00:00 2001 From: Subrahmanyaman Date: Fri, 24 Jun 2022 16:32:16 +0000 Subject: [PATCH] Fixed the issue in isKeyMintRedy function --- .../javacard/keymaster/KMKeymasterApplet.java | 4 ++-- .../javacard/keymaster/KMKeymintDataStore.java | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java index ebde5d27..03d8369b 100644 --- a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java +++ b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java @@ -456,7 +456,7 @@ public void process(APDU apdu) { } byte[] apduBuffer = apdu.getBuffer(); byte apduIns = apduBuffer[ISO7816.OFFSET_INS]; - if (!isKeymintReady(apduIns)) { + if (!isKeyMintReady(apduIns)) { ISOException.throwIt(ISO7816.SW_COMMAND_NOT_ALLOWED); } switch (apduIns) { @@ -568,7 +568,7 @@ public void process(APDU apdu) { // 1. boot parameters are set, // 2. system properties are set and // 3. computed the shared secret successfully. - private boolean isKeymintReady(byte apduIns) { + private boolean isKeyMintReady(byte apduIns) { if(kmDataStore.isDeviceReady()) { return true; } diff --git a/Applet/src/com/android/javacard/keymaster/KMKeymintDataStore.java b/Applet/src/com/android/javacard/keymaster/KMKeymintDataStore.java index 4380cb67..c65e4d8e 100644 --- a/Applet/src/com/android/javacard/keymaster/KMKeymintDataStore.java +++ b/Applet/src/com/android/javacard/keymaster/KMKeymintDataStore.java @@ -345,12 +345,12 @@ public void setDeviceBootStatus(byte initStatus) { } public boolean isDeviceReady() { - boolean result = false; - short offset = repository.allocReclaimableMemory(DEVICE_STATUS_FLAG_SIZE); - byte[] buf = repository.getHeap(); - getDeviceBootStatus(buf, offset); - byte bootCompleteStatus = SET_BOOT_PARAMS_SUCCESS | SET_SYSTEM_PROPERTIES_SUCCESS | - SET_SYSTEM_PROPERTIES_SUCCESS; + boolean result = false; + short offset = repository.allocReclaimableMemory(DEVICE_STATUS_FLAG_SIZE); + byte[] buf = repository.getHeap(); + getDeviceBootStatus(buf, offset); + byte bootCompleteStatus = (SET_BOOT_PARAMS_SUCCESS | SET_SYSTEM_PROPERTIES_SUCCESS | + NEGOTIATED_SHARED_SECRET_SUCCESS); if (bootCompleteStatus == (buf[offset] & bootCompleteStatus)) { result = true; }