Hook in user authenticators and their exceptions.
Bug: 18088752 Change-Id: I2835dbe51d09587a3081597c6aaf536aa1427e24
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user