diff options
Diffstat (limited to 'keystore/java/android/security/KeymasterUtils.java')
-rw-r--r-- | keystore/java/android/security/KeymasterUtils.java | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/keystore/java/android/security/KeymasterUtils.java b/keystore/java/android/security/KeymasterUtils.java index 7bf5475..aa44ecd 100644 --- a/keystore/java/android/security/KeymasterUtils.java +++ b/keystore/java/android/security/KeymasterUtils.java @@ -18,12 +18,8 @@ package android.security; import android.content.Context; import android.hardware.fingerprint.FingerprintManager; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.os.UserHandle; import android.security.keymaster.KeymasterArguments; import android.security.keymaster.KeymasterDefs; -import android.service.gatekeeper.IGateKeeperService; import libcore.util.EmptyArray; @@ -183,22 +179,22 @@ public abstract class KeymasterUtils { return result; } - public static int getDigestOutputSizeBytes(int keymasterDigest) { + public static int getDigestOutputSizeBits(int keymasterDigest) { switch (keymasterDigest) { case KeymasterDefs.KM_DIGEST_NONE: return -1; case KeymasterDefs.KM_DIGEST_MD5: - return 128 / 8; + return 128; case KeymasterDefs.KM_DIGEST_SHA1: - return 160 / 8; + return 160; case KeymasterDefs.KM_DIGEST_SHA_2_224: - return 224 / 8; + return 224; case KeymasterDefs.KM_DIGEST_SHA_2_256: - return 256 / 8; + return 256; case KeymasterDefs.KM_DIGEST_SHA_2_384: - return 384 / 8; + return 384; case KeymasterDefs.KM_DIGEST_SHA_2_512: - return 512 / 8; + return 512; default: throw new IllegalArgumentException("Unknown digest: " + keymasterDigest); } @@ -347,20 +343,6 @@ public abstract class KeymasterUtils { return result; } - private static long getRootSid() { - IGateKeeperService gatekeeperService = IGateKeeperService.Stub.asInterface( - ServiceManager.getService("android.service.gatekeeper.IGateKeeperService")); - if (gatekeeperService == null) { - throw new IllegalStateException("Gatekeeper service not available"); - } - - try { - return gatekeeperService.getSecureUserId(UserHandle.myUserId()); - } catch (RemoteException e) { - throw new IllegalStateException("Failed to obtain root SID"); - } - } - /** * Adds keymaster arguments to express the key's authorization policy supported by user * authentication. @@ -402,7 +384,7 @@ public abstract class KeymasterUtils { } else { // The key is authorized for use for the specified amount of time after the user has // authenticated. Whatever unlocks the secure lock screen should authorize this key. - long rootSid = getRootSid(); + long rootSid = GateKeeper.getSecureUserId(); if (rootSid == 0) { throw new IllegalStateException("Secure lock screen must be enabled" + " to create keys requiring user authentication"); |