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

Commit 93d002ca authored by Robert Berry's avatar Robert Berry
Browse files

Unhide RecoveryController#getRootCertificates()

This is so we can add a GTS test to affirm that GMS devices include the
Google Cloud Key Vault root certificate.

Test: runtest frameworks-core -p android.security.keystore.recovery
Bug: 74621045
Change-Id: Ib6431f5739f3dff066832e6aa300dd9da5bc0727
parent 98ea60c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4371,6 +4371,7 @@ package android.security.keystore.recovery {
    method public int[] getRecoverySecretTypes() 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 int getRecoveryStatus(java.lang.String) throws android.security.keystore.recovery.InternalRecoveryServiceException;
    method public java.util.Map<java.lang.String, java.security.cert.X509Certificate> getRootCertificates();
    method public java.security.Key importKey(java.lang.String, byte[]) throws android.security.keystore.recovery.InternalRecoveryServiceException, android.security.keystore.recovery.LockScreenRequiredException;
    method public deprecated void initRecoveryService(java.lang.String, byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
    method public void initRecoveryService(java.lang.String, byte[], byte[]) throws java.security.cert.CertificateException, android.security.keystore.recovery.InternalRecoveryServiceException;
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import java.security.Key;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertPath;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -654,6 +655,11 @@ public class RecoveryController {
        return RecoverySession.newInstance(this);
    }

    @RequiresPermission(android.Manifest.permission.RECOVER_KEYSTORE)
    public Map<String, X509Certificate> getRootCertificates() {
        return TrustedRootCertificates.getRootCertificates();
    }

    InternalRecoveryServiceException wrapUnexpectedServiceSpecificException(
            ServiceSpecificException e) {
        if (e.errorCode == ERROR_SERVICE_INTERNAL_ERROR) {
+5 −2
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ import java.util.Map;
 *
 * @hide
 */
public class TrustedRootCertificates {
public final class TrustedRootCertificates {

    public static final String GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS =
            "GoogleCloudKeyVaultServiceV1";
@@ -83,7 +83,7 @@ public class TrustedRootCertificates {
    /**
     * Returns all available root certificates, keyed by alias.
     */
    public static Map<String, X509Certificate> listRootCertificates() {
    public static Map<String, X509Certificate> getRootCertificates() {
        return new ArrayMap(ALL_ROOT_CERTIFICATES);
    }

@@ -114,4 +114,7 @@ public class TrustedRootCertificates {
            throw new RuntimeException(e);
        }
    }

    // Statics only
    private TrustedRootCertificates() {}
}
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

package android.security.keystore.recovery;

import static android.security.keystore.recovery.TrustedRootCertificates.listRootCertificates;
import static android.security.keystore.recovery.TrustedRootCertificates.getRootCertificates;

import static org.junit.Assert.assertTrue;

@@ -36,8 +36,8 @@ public class TrustedRootCertificatesTest {
            "GoogleCloudKeyVaultServiceV1";

    @Test
    public void listRootCertificates_listsGoogleCloudVaultV1Certificate() {
        Map<String, X509Certificate> certificates = listRootCertificates();
    public void getRootCertificates_listsGoogleCloudVaultV1Certificate() {
        Map<String, X509Certificate> certificates = getRootCertificates();

        assertTrue(certificates.containsKey(GOOGLE_CLOUD_KEY_VAULT_SERVICE_V1_ALIAS));
    }