Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a620aa1a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Remove account param from generateKey method"

parents bb5b0951 a3b99479
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -4297,6 +4297,7 @@ package android.security.keystore.recovery {
  public class RecoveryController {
  public class RecoveryController {
    method public android.security.keystore.recovery.RecoverySession createRecoverySession();
    method public android.security.keystore.recovery.RecoverySession createRecoverySession();
    method public byte[] generateAndStoreKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public byte[] generateAndStoreKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public java.security.Key generateKey(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public java.util.List<java.lang.String> getAliases() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public java.util.List<java.lang.String> getAliases() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public static android.security.keystore.recovery.RecoveryController getInstance(android.content.Context);
    method public static android.security.keystore.recovery.RecoveryController getInstance(android.content.Context);
    method public int[] getPendingRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public int[] getPendingRecoverySecretTypes() throws android.security.keystore.recovery.InternalRecoveryServiceException;
+1 −0
Original line number Original line Diff line number Diff line
@@ -98,6 +98,7 @@ package android.security.keystore.recovery {
  }
  }


  public class RecoveryController {
  public class RecoveryController {
    method public deprecated java.security.Key generateKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public deprecated java.util.List<java.lang.String> getAliases(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated java.util.List<java.lang.String> getAliases(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated android.security.keystore.recovery.KeyChainSnapshot getRecoveryData() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated android.security.keystore.recovery.KeyChainSnapshot getRecoveryData() throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated int getRecoveryStatus(java.lang.String, java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public deprecated int getRecoveryStatus(java.lang.String, java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
+19 −16
Original line number Original line Diff line number Diff line
@@ -462,35 +462,38 @@ public class RecoveryController {
    }
    }


    /**
    /**
     * Generates a AES256/GCM/NoPADDING key called {@code alias} and loads it into the recoverable
     * @deprecated Use {@link #generateKey(String)}.
     * key store. Returns {@link javax.crypto.SecretKey}.
     * @removed
     */
    @Deprecated
    public Key generateKey(@NonNull String alias, byte[] account)
            throws InternalRecoveryServiceException, LockScreenRequiredException {
        return generateKey(alias);
    }

    /**
     * Generates a recoverable key with the given {@code alias}.
     *
     *
     * @param alias The key alias.
     * @param account The account associated with the key.
     * @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery
     * @throws InternalRecoveryServiceException if an unexpected error occurred in the recovery
     *     service.
     *     service.
     * @throws LockScreenRequiredException if the user has not set a lock screen. This is required
     * @throws LockScreenRequiredException if the user does not have a lock screen set. A lock
     *     to generate recoverable keys, as the snapshots are encrypted using a key derived from the
     *     screen is required to generate recoverable keys.
     *     lock screen.
     * @hide
     */
     */
    public Key generateKey(@NonNull String alias, byte[] account)
    public Key generateKey(@NonNull String alias) throws InternalRecoveryServiceException,
            throws InternalRecoveryServiceException, LockScreenRequiredException {
            LockScreenRequiredException {
        // TODO: update RecoverySession.recoverKeys
        try {
        try {
            String grantAlias = mBinder.generateKey(alias, account);
            String grantAlias = mBinder.generateKey(alias);
            if (grantAlias == null) {
            if (grantAlias == null) {
                return null;
                throw new InternalRecoveryServiceException("null grant alias");
            }
            }
            Key result = AndroidKeyStoreProvider.loadAndroidKeyStoreKeyFromKeystore(
            return AndroidKeyStoreProvider.loadAndroidKeyStoreKeyFromKeystore(
                    mKeyStore,
                    mKeyStore,
                    grantAlias,
                    grantAlias,
                    KeyStore.UID_SELF);
                    KeyStore.UID_SELF);
            return result;
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
            throw e.rethrowFromSystemServer();
        } catch (UnrecoverableKeyException e) {
        } catch (UnrecoverableKeyException e) {
            throw new InternalRecoveryServiceException("Access to newly generated key failed for");
            throw new InternalRecoveryServiceException("Failed to get key from keystore", e);
        } catch (ServiceSpecificException e) {
        } catch (ServiceSpecificException e) {
            if (e.errorCode == ERROR_INSECURE_USER) {
            if (e.errorCode == ERROR_INSECURE_USER) {
                throw new LockScreenRequiredException(e.getMessage());
                throw new LockScreenRequiredException(e.getMessage());
+1 −1
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@ interface ILockSettings {
    void initRecoveryService(in String rootCertificateAlias, in byte[] signedPublicKeyList);
    void initRecoveryService(in String rootCertificateAlias, in byte[] signedPublicKeyList);
    KeyChainSnapshot getKeyChainSnapshot();
    KeyChainSnapshot getKeyChainSnapshot();
    byte[] generateAndStoreKey(String alias);
    byte[] generateAndStoreKey(String alias);
    String generateKey(String alias, in byte[] account);
    String generateKey(String alias);
    String getKey(String alias);
    String getKey(String alias);
    void removeKey(String alias);
    void removeKey(String alias);
    void setSnapshotCreatedPendingIntent(in PendingIntent intent);
    void setSnapshotCreatedPendingIntent(in PendingIntent intent);
+2 −2
Original line number Original line Diff line number Diff line
@@ -2074,8 +2074,8 @@ public class LockSettingsService extends ILockSettings.Stub {
    }
    }


    @Override
    @Override
    public String generateKey(@NonNull String alias, byte[] account) throws RemoteException {
    public String generateKey(@NonNull String alias) throws RemoteException {
        return mRecoverableKeyStoreManager.generateKey(alias, account);
        return mRecoverableKeyStoreManager.generateKey(alias);
    }
    }


    @Override
    @Override
Loading