Skip to content

Commit b9dae94

Browse files
authored
Merge pull request #233 from subrahmanyaman/import_wrapped_key_fix
Unwrapping params should have SH256 and RSA_OAEP as digest and padding
2 parents aa81641 + 547ab3f commit b9dae94

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Applet/src/com/android/javacard/keymaster/KMKeymasterApplet.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,15 @@ private void validateWrappingKeyBlob(){
13621362
if (!KMEnumArrayTag.contains(KMType.PURPOSE, KMType.WRAP_KEY, data[HW_PARAMETERS])) {
13631363
KMException.throwIt((KMError.INCOMPATIBLE_PURPOSE));
13641364
}
1365+
1366+
// Check that the digest and padding mode specified in unwrapping parameters are SHA2_256
1367+
// and RSA_OAEP respectively.
1368+
if (!KMEnumArrayTag.contains(KMType.DIGEST, KMType.SHA2_256, data[KEY_PARAMETERS])) {
1369+
KMException.throwIt(KMError.INCOMPATIBLE_DIGEST);
1370+
}
1371+
if (!KMEnumArrayTag.contains(KMType.PADDING, KMType.RSA_OAEP, data[KEY_PARAMETERS])) {
1372+
KMException.throwIt(KMError.INCOMPATIBLE_PADDING_MODE);
1373+
}
13651374
}
13661375

13671376
private short decryptTransportKey(short privExp, short modulus, short transportKey, byte[] scratchPad){

0 commit comments

Comments
 (0)