From 2f2879e7989ce8a7f045140ea1a67f507c423d2d Mon Sep 17 00:00:00 2001 From: subrahmanyaman Date: Tue, 15 Nov 2022 05:43:38 +0000 Subject: [PATCH] Correction in the calcuclation of RSA KeySize in importKey --- .../src/com/android/javacard/keymaster/KMKeymasterApplet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java index da8aa4b7..f03dc7fb 100644 --- a/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java +++ b/Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java @@ -3542,7 +3542,7 @@ private void importRSAKey(byte[] scratchPad) { // check the keysize tag if present in key parameters. short keysize = KMIntegerTag.getShortValue(KMType.UINT_TAG, KMType.KEYSIZE, data[KEY_PARAMETERS]); - short kSize = (short) (KMByteBlob.length(data[SECRET]) * 8); + short kSize = (short) (KMByteBlob.length(data[PUB_KEY]) * 8); if (keysize != KMType.INVALID_VALUE) { if (keysize != 2048 || (keysize != kSize)) { KMException.throwIt(KMError.IMPORT_PARAMETER_MISMATCH);