From f039c744a6b4a4a47785f28a3468bf8e4f4e1b02 Mon Sep 17 00:00:00 2001 From: subrahmanyaman Date: Thu, 24 Nov 2022 03:07:02 +0000 Subject: [PATCH] Fixed the Functional Test in importWrappedKey --- .../android/javacard/test/KMFunctionalTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Applet/JCardSimProvider/test/com/android/javacard/test/KMFunctionalTest.java b/Applet/JCardSimProvider/test/com/android/javacard/test/KMFunctionalTest.java index 43f8e132..f420b8f4 100644 --- a/Applet/JCardSimProvider/test/com/android/javacard/test/KMFunctionalTest.java +++ b/Applet/JCardSimProvider/test/com/android/javacard/test/KMFunctionalTest.java @@ -2359,7 +2359,20 @@ public ResponseAPDU importWrappedKey() { (short) wrappingKeyBlob.length)); // Wrapping Key KeyBlob KMArray.cast(arr).add((short) 2, KMByteBlob.instance(maskingKey, (short) 0, (short) maskingKey.length)); // Masking Key - KMArray.cast(arr).add((short) 3, nullParams); // unwrapping params + // RSA OAEP Padding + short paddingBlob = KMByteBlob.instance((short) 1); + KMByteBlob.cast(paddingBlob).add((short) 0, KMType.RSA_OAEP); + short padding = KMEnumArrayTag.instance(KMType.PADDING, paddingBlob); + // Unwrapping params should have Digest: SHA256 and padding as RSA_OAEP + short unwrappingParamsArr = KMArray.instance((short) 2); + // SHA256 digest + short digestBlob = KMByteBlob.instance((short) 1); + KMByteBlob.cast(digestBlob).add((short) 0, KMType.SHA2_256); + short digest = KMEnumArrayTag.instance(KMType.DIGEST, digestBlob); + KMArray.cast(unwrappingParamsArr).add((short) 0, padding); + KMArray.cast(unwrappingParamsArr).add((short) 1, digest); + short unwrappingParams = KMKeyParameters.instance(unwrappingParamsArr); + KMArray.cast(arr).add((short) 3, unwrappingParams); // unwrapping params CommandAPDU apdu = KMTestUtils.encodeApdu(encoder, (byte) INS_BEGIN_IMPORT_WRAPPED_KEY_CMD, arr); ResponseAPDU response = simulator.transmitCommand(apdu);