diff options
Diffstat (limited to 'keystore/java/android/security/KeymasterUtils.java')
-rw-r--r-- | keystore/java/android/security/KeymasterUtils.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/keystore/java/android/security/KeymasterUtils.java b/keystore/java/android/security/KeymasterUtils.java index 6bb9636..2645cf4 100644 --- a/keystore/java/android/security/KeymasterUtils.java +++ b/keystore/java/android/security/KeymasterUtils.java @@ -29,7 +29,7 @@ import java.util.List; public abstract class KeymasterUtils { private KeymasterUtils() {} - public static KeymasterException getExceptionForKeymasterError(int keymasterErrorCode) { + public static KeymasterException getKeymasterException(int keymasterErrorCode) { switch (keymasterErrorCode) { case KeymasterDefs.KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT: // The name of this parameter significantly differs between Keymaster and framework @@ -42,6 +42,19 @@ public abstract class KeymasterUtils { } } + public static CryptoOperationException getCryptoOperationException(KeymasterException e) { + switch (e.getErrorCode()) { + case KeymasterDefs.KM_ERROR_KEY_USER_NOT_AUTHENTICATED: + return new UserNotAuthenticatedException(); + default: + return new CryptoOperationException("Crypto operation failed", e); + } + } + + public static CryptoOperationException getCryptoOperationException(int keymasterErrorCode) { + return getCryptoOperationException(getKeymasterException(keymasterErrorCode)); + } + public static Integer getInt(KeyCharacteristics keyCharacteristics, int tag) { if (keyCharacteristics.hwEnforced.containsTag(tag)) { return keyCharacteristics.hwEnforced.getInt(tag, -1); |