fix(interception): check generatedKeys before deletedSoftwareKeys on getKeyEntry

The deletion guard must not shadow re-generated keys. If an app
deletes a key then re-creates it, getKeyEntry was still returning
KEY_NOT_FOUND because deletedSoftwareKeys was checked first.
This commit is contained in:
Enginex0
2026-03-16 22:36:02 +01:00
parent 8bdf0d59fa
commit 90ff59e0aa
@@ -172,15 +172,15 @@ object Keystore2Interceptor : AbstractKeystoreInterceptor() {
return TransactionResult.ContinueAndSkipPost return TransactionResult.ContinueAndSkipPost
} }
if (keyId in deletedSoftwareKeys) { val response = KeyMintSecurityLevelInterceptor.getGeneratedKeyResponse(keyId)
SystemLogger.info("[TX_ID: $txId] Returning KEY_NOT_FOUND for deleted key ${descriptor.alias}") if (response == null) {
return InterceptorUtils.createErrorReply(RESPONSE_KEY_NOT_FOUND) if (deletedSoftwareKeys.remove(keyId)) {
SystemLogger.info("[TX_ID: $txId] Returning KEY_NOT_FOUND for deleted key ${descriptor.alias}")
return InterceptorUtils.createErrorReply(RESPONSE_KEY_NOT_FOUND)
}
return TransactionResult.Continue
} }
val response =
KeyMintSecurityLevelInterceptor.getGeneratedKeyResponse(keyId)
?: return TransactionResult.Continue
if (KeyMintSecurityLevelInterceptor.isAttestationKey(keyId)) if (KeyMintSecurityLevelInterceptor.isAttestationKey(keyId))
SystemLogger.info("${descriptor.alias} was an attestation key") SystemLogger.info("${descriptor.alias} was an attestation key")