fix(interception): reject EC+DECRYPT in createOperation
EC keys don't support DECRYPT (only AGREE_KEY for key derivation). Without this guard, an EC DECRYPT operation creates a CipherPrimitive that fails with a confusing JCA error instead of returning UNSUPPORTED_PURPOSE upfront.
This commit is contained in:
+2
-1
@@ -328,7 +328,8 @@ class KeyMintSecurityLevelInterceptor(
|
||||
(isAsymmetric &&
|
||||
(requestedPurpose == KeyPurpose.VERIFY ||
|
||||
requestedPurpose == KeyPurpose.ENCRYPT)) ||
|
||||
(requestedPurpose == KeyPurpose.AGREE_KEY && algorithm != Algorithm.EC)
|
||||
(requestedPurpose == KeyPurpose.AGREE_KEY && algorithm != Algorithm.EC) ||
|
||||
(algorithm == Algorithm.EC && requestedPurpose == KeyPurpose.DECRYPT)
|
||||
if (unsupported) {
|
||||
return InterceptorUtils.createServiceSpecificErrorReply(
|
||||
KeystoreErrorCode.UNSUPPORTED_PURPOSE
|
||||
|
||||
Reference in New Issue
Block a user