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

Commit 4051120f authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Keystore 2 SPI: Fix KeyStorePublicKey getEncoded()." am: 9e538579 am:...

Merge "Keystore 2 SPI: Fix KeyStorePublicKey getEncoded()." am: 9e538579 am: 05088254 am: a38be41f am: 35fe58bb

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1559984

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idb0897f7e21792817134d92c7894be409d6e0015
parents d658c9b3 35fe58bb
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -38,9 +38,10 @@ public class AndroidKeyStoreECPublicKey extends AndroidKeyStorePublicKey impleme

    public AndroidKeyStoreECPublicKey(@NonNull KeyDescriptor descriptor,
            @NonNull KeyMetadata metadata,
            @NonNull byte[] x509EncodedForm,
            @NonNull KeyStoreSecurityLevel securityLevel,
            @NonNull ECParameterSpec params, @NonNull ECPoint w) {
        super(descriptor, metadata, KeyProperties.KEY_ALGORITHM_EC, securityLevel);
        super(descriptor, metadata, x509EncodedForm, KeyProperties.KEY_ALGORITHM_EC, securityLevel);
        mParams = params;
        mW = w;
    }
@@ -48,7 +49,7 @@ public class AndroidKeyStoreECPublicKey extends AndroidKeyStorePublicKey impleme
    public AndroidKeyStoreECPublicKey(@NonNull KeyDescriptor descriptor,
            @NonNull KeyMetadata metadata,
            @NonNull KeyStoreSecurityLevel securityLevel, @NonNull ECPublicKey info) {
        this(descriptor, metadata, securityLevel, info.getParams(), info.getW());
        this(descriptor, metadata, info.getEncoded(), securityLevel, info.getParams(), info.getW());
        if (!"X.509".equalsIgnoreCase(info.getFormat())) {
            throw new IllegalArgumentException(
                    "Unsupported key export format: " + info.getFormat());
+5 −3
Original line number Diff line number Diff line
@@ -32,13 +32,15 @@ import java.security.PublicKey;
public abstract class AndroidKeyStorePublicKey extends AndroidKeyStoreKey implements PublicKey {
    private final byte[] mCertificate;
    private final byte[] mCertificateChain;
    private final byte[] mEncoded;

    public AndroidKeyStorePublicKey(@NonNull KeyDescriptor descriptor,
            @NonNull KeyMetadata metadata, @NonNull String algorithm,
            @NonNull KeyStoreSecurityLevel securityLevel) {
            @NonNull KeyMetadata metadata, @NonNull byte[] x509EncodedForm,
            @NonNull String algorithm, @NonNull KeyStoreSecurityLevel securityLevel) {
        super(descriptor, metadata.key.nspace, metadata.authorizations, algorithm, securityLevel);
        mCertificate = metadata.certificate;
        mCertificateChain = metadata.certificateChain;
        mEncoded = x509EncodedForm;
    }

    abstract AndroidKeyStorePrivateKey getPrivateKey();
@@ -50,7 +52,7 @@ public abstract class AndroidKeyStorePublicKey extends AndroidKeyStoreKey implem

    @Override
    public byte[] getEncoded() {
        return ArrayUtils.cloneIfNotEmpty(mCertificate);
        return ArrayUtils.cloneIfNotEmpty(mEncoded);
    }

    @Override
+5 −2
Original line number Diff line number Diff line
@@ -36,9 +36,11 @@ public class AndroidKeyStoreRSAPublicKey extends AndroidKeyStorePublicKey implem

    public AndroidKeyStoreRSAPublicKey(@NonNull KeyDescriptor descriptor,
            @NonNull KeyMetadata metadata,
            @NonNull byte[] x509EncodedForm,
            @NonNull KeyStoreSecurityLevel securityLevel, @NonNull BigInteger modulus,
            @NonNull BigInteger publicExponent) {
        super(descriptor, metadata, KeyProperties.KEY_ALGORITHM_RSA, securityLevel);
        super(descriptor, metadata, x509EncodedForm, KeyProperties.KEY_ALGORITHM_RSA,
                securityLevel);
        mModulus = modulus;
        mPublicExponent = publicExponent;
    }
@@ -46,7 +48,8 @@ public class AndroidKeyStoreRSAPublicKey extends AndroidKeyStorePublicKey implem
    public AndroidKeyStoreRSAPublicKey(@NonNull KeyDescriptor descriptor,
            @NonNull KeyMetadata metadata,
            @NonNull KeyStoreSecurityLevel securityLevel, @NonNull RSAPublicKey info) {
        this(descriptor, metadata, securityLevel, info.getModulus(), info.getPublicExponent());
        this(descriptor, metadata, info.getEncoded(), securityLevel, info.getModulus(),
                info.getPublicExponent());
        if (!"X.509".equalsIgnoreCase(info.getFormat())) {
            throw new IllegalArgumentException(
                    "Unsupported key export format: " + info.getFormat());