Merge "Specify UID in getAuthenticatorIds" into sc-dev

This commit is contained in:
TreeHugger Robot
2021-04-27 00:00:14 +00:00
committed by Android (Google) Code Review
3 changed files with 24 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ import android.annotation.TestApi;
import android.content.Context;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.security.keystore.KeyProperties;
import android.util.Slog;
@@ -556,9 +557,22 @@ public class BiometricManager {
* @hide
*/
public long[] getAuthenticatorIds() {
return getAuthenticatorIds(UserHandle.getCallingUserId());
}
/**
* Get a list of AuthenticatorIDs for biometric authenticators which have 1) enrolled templates,
* and 2) meet the requirements for integrating with Keystore. The AuthenticatorIDs are known
* in Keystore land as SIDs, and are used during key generation.
*
* @param userId Android user ID for user to look up.
*
* @hide
*/
public long[] getAuthenticatorIds(int userId) {
if (mService != null) {
try {
return mService.getAuthenticatorIds();
return mService.getAuthenticatorIds(userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -67,7 +67,9 @@ interface IAuthService {
// Get a list of AuthenticatorIDs for authenticators which have enrolled templates and meet
// the requirements for integrating with Keystore. The AuthenticatorID are known in Keystore
// land as SIDs, and are used during key generation.
long[] getAuthenticatorIds();
// If userId is not equal to the calling user ID, the caller must have the
// USE_BIOMETRIC_INTERNAL permission.
long[] getAuthenticatorIds(in int userId);
// See documentation in BiometricManager.
void resetLockoutTimeBound(IBinder token, String opPackageName, int fromSensorId, int userId,

View File

@@ -337,7 +337,7 @@ public class AuthService extends SystemService {
}
@Override
public long[] getAuthenticatorIds() throws RemoteException {
public long[] getAuthenticatorIds(int userId) throws RemoteException {
// In this method, we're not checking whether the caller is permitted to use face
// API because current authenticator ID is leaked (in a more contrived way) via Android
// Keystore (android.security.keystore package): the user of that API can create a key
@@ -355,9 +355,13 @@ public class AuthService extends SystemService {
// method from inside app processes.
final int callingUserId = UserHandle.getCallingUserId();
if (userId != callingUserId) {
getContext().enforceCallingOrSelfPermission(USE_BIOMETRIC_INTERNAL,
"Must have " + USE_BIOMETRIC_INTERNAL + " permission.");
}
final long identity = Binder.clearCallingIdentity();
try {
return mBiometricService.getAuthenticatorIds(callingUserId);
return mBiometricService.getAuthenticatorIds(userId);
} finally {
Binder.restoreCallingIdentity(identity);
}