From 750b71c6512dad08e9c8eb59c2ad3c0d4fcfe79f Mon Sep 17 00:00:00 2001 From: Robert Berry Date: Wed, 21 Mar 2018 16:31:52 +0000 Subject: [PATCH] Unhide RecoverySession#recoverKeyChainSnapshot() method The other methods expose raw key materials, which is a security flaw. This new API is already being used by GMSCore, via reflection (although falling back to the old methods if it is not available). Would be good to switch it on ASAP. Bug: 74345822 Test: Tested with GMSCore Change-Id: I30d53c9e825888d1122c72d23b7c1c10c6edb1e9 --- api/system-current.txt | 3 ++- .../keystore/recovery/RecoverySession.java | 14 ++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/api/system-current.txt b/api/system-current.txt index 4c03142db0d86..2ffa7eb547e13 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4388,7 +4388,8 @@ package android.security.keystore.recovery { public class RecoverySession implements java.lang.AutoCloseable { method public void close(); - method public java.util.Map recoverKeys(byte[], java.util.List) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; + method public java.util.Map recoverKeyChainSnapshot(byte[], java.util.List) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; + method public deprecated java.util.Map recoverKeys(byte[], java.util.List) throws android.security.keystore.recovery.DecryptionFailedException, android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.SessionExpiredException; method public deprecated byte[] start(byte[], byte[], byte[], java.util.List) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; method public deprecated byte[] start(java.security.cert.CertPath, byte[], byte[], java.util.List) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; method public byte[] start(java.lang.String, java.security.cert.CertPath, byte[], byte[], java.util.List) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException; diff --git a/core/java/android/security/keystore/recovery/RecoverySession.java b/core/java/android/security/keystore/recovery/RecoverySession.java index f61569e68a7d6..208b9b2c2dd88 100644 --- a/core/java/android/security/keystore/recovery/RecoverySession.java +++ b/core/java/android/security/keystore/recovery/RecoverySession.java @@ -197,17 +197,9 @@ public class RecoverySession implements AutoCloseable { } /** - * Imports keys. - * - * @param recoveryKeyBlob Recovery blob encrypted by symmetric key generated for this session. - * @param applicationKeys Application keys. Key material can be decrypted using recoveryKeyBlob - * and session. KeyStore only uses package names from the application info in {@link - * WrappedApplicationKey}. Caller is responsibility to perform certificates check. - * @return Map from alias to raw key material. - * @throws SessionExpiredException if {@code session} has since been closed. - * @throws DecryptionFailedException if unable to decrypt the snapshot. - * @throws InternalRecoveryServiceException if an error occurs internal to the recovery service. + * @deprecated Use {@link #recoverKeyChainSnapshot(byte[], List)} instead. */ + @Deprecated @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE) public Map recoverKeys( @NonNull byte[] recoveryKeyBlob, @@ -239,8 +231,6 @@ public class RecoverySession implements AutoCloseable { * @throws SessionExpiredException if {@code session} has since been closed. * @throws DecryptionFailedException if unable to decrypt the snapshot. * @throws InternalRecoveryServiceException if an error occurs internal to the recovery service. - * - * @hide */ @RequiresPermission(Manifest.permission.RECOVER_KEYSTORE) public Map recoverKeyChainSnapshot(