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

Commit 9a3db4e5 authored by Alex Klyubin's avatar Alex Klyubin Committed by Android Git Automerger
Browse files

am 21a0f80f: am 5eaf2412: am 10633c96: Merge "Fix Android Keystore key...

am 21a0f80f: am 5eaf2412: am 10633c96: Merge "Fix Android Keystore key factories to obey JCA contract." into mnc-dev

* commit '21a0f80f':
  Fix Android Keystore key factories to obey JCA contract.
parents 1e01d621 21a0f80f
Loading
Loading
Loading
Loading
+13 −8
Original line number Original line Diff line number Diff line
@@ -124,22 +124,27 @@ public class AndroidKeyStoreKeyFactorySpi extends KeyFactorySpi {


    @Override
    @Override
    protected PrivateKey engineGeneratePrivate(KeySpec spec) throws InvalidKeySpecException {
    protected PrivateKey engineGeneratePrivate(KeySpec spec) throws InvalidKeySpecException {
        throw new UnsupportedOperationException(
        throw new InvalidKeySpecException(
                "To generate a key pair in Android KeyStore, use KeyPairGenerator initialized with"
                "To generate a key pair in Android Keystore, use KeyPairGenerator initialized with"
                + " " + KeyGenParameterSpec.class.getName());
                + " " + KeyGenParameterSpec.class.getName());
    }
    }


    @Override
    @Override
    protected PublicKey engineGeneratePublic(KeySpec spec) throws InvalidKeySpecException {
    protected PublicKey engineGeneratePublic(KeySpec spec) throws InvalidKeySpecException {
        throw new UnsupportedOperationException(
        throw new InvalidKeySpecException(
                "To generate a key pair in Android KeyStore, use KeyPairGenerator initialized with"
                "To generate a key pair in Android Keystore, use KeyPairGenerator initialized with"
                + " " + KeyGenParameterSpec.class.getName());
                + " " + KeyGenParameterSpec.class.getName());
    }
    }


    @Override
    @Override
    protected Key engineTranslateKey(Key arg0) throws InvalidKeyException {
    protected Key engineTranslateKey(Key key) throws InvalidKeyException {
        throw new UnsupportedOperationException(
        if (key == null) {
                "To import a key into Android KeyStore, use KeyStore.setEntry with "
            throw new InvalidKeyException("key == null");
                + KeyProtection.class.getName());
        } else if ((!(key instanceof AndroidKeyStorePrivateKey))
                && (!(key instanceof AndroidKeyStorePublicKey))) {
            throw new InvalidKeyException(
                    "To import a key into Android Keystore, use KeyStore.setEntry");
        }
        return key;
    }
    }
}
}
+10 −5
Original line number Original line Diff line number Diff line
@@ -185,15 +185,20 @@ public class AndroidKeyStoreSecretKeyFactorySpi extends SecretKeyFactorySpi {


    @Override
    @Override
    protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException {
    protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException {
        throw new UnsupportedOperationException(
        throw new InvalidKeySpecException(
                "To generate secret key in Android KeyStore, use KeyGenerator initialized with "
                "To generate secret key in Android Keystore, use KeyGenerator initialized with "
                        + KeyGenParameterSpec.class.getName());
                        + KeyGenParameterSpec.class.getName());
    }
    }


    @Override
    @Override
    protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException {
    protected SecretKey engineTranslateKey(SecretKey key) throws InvalidKeyException {
        throw new UnsupportedOperationException(
        if (key == null) {
                "To import a secret key into Android KeyStore, use KeyStore.setEntry with "
            throw new InvalidKeyException("key == null");
                + KeyProtection.class.getName());
        } else if (!(key instanceof AndroidKeyStoreSecretKey)) {
            throw new InvalidKeyException(
                    "To import a secret key into Android Keystore, use KeyStore.setEntry");
        }

        return key;
    }
    }
}
}