Hook in user authenticators and their exceptions.

Bug: 18088752
Change-Id: I2835dbe51d09587a3081597c6aaf536aa1427e24
This commit is contained in:
Alex Klyubin
2015-03-31 19:50:13 -07:00
parent b7a34e4955
commit c8e557470f
9 changed files with 159 additions and 30 deletions

View File

@@ -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);