Skip to content

Commit

Permalink
Fixed the Functional Test in importWrappedKey
Browse files Browse the repository at this point in the history
  • Loading branch information
subrahmanyaman committed Nov 24, 2022
1 parent ce64ea8 commit f039c74
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f039c74

Please sign in to comment.