Alex Klyubin 4ab8ea4498 Add HmacSHA256 backed by AndroidKeyStore.
This also adds the MAC length constraint on imported HMAC keys. HMAC
doesn't work without this constraint at the moment.

Bug: 18088752
Change-Id: I8613f58f5d2a84df00bcf6179d13e30619440330
2015-03-30 12:53:23 -07:00

24 lines
876 B
Java

package android.security;
import android.security.keymaster.KeymasterDefs;
/**
* @hide
*/
public abstract class KeymasterUtils {
private KeymasterUtils() {}
public static KeymasterException getExceptionForKeymasterError(int keymasterErrorCode) {
switch (keymasterErrorCode) {
case KeymasterDefs.KM_ERROR_INVALID_AUTHORIZATION_TIMEOUT:
// The name of this parameter significantly differs between Keymaster and framework
// APIs. Use the framework wording to make life easier for developers.
return new KeymasterException(keymasterErrorCode,
"Invalid user authentication validity duration");
default:
return new KeymasterException(keymasterErrorCode,
KeymasterDefs.getErrorMessage(keymasterErrorCode));
}
}
}