I generated and store RSA key into android keyStore , then I generated an AES key and encrypt that with RSA public-key, when i want to decrypt encrypted-AES-key i got this error :java.security.InvalidKeyException: Need RSA private or public key
KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) keyStore.getEntry(KEY_ALIAS, null);
Cipher output = Cipher.getInstance(RSA_MODE, "AndroidOpenSSL");
output.init(Cipher.DECRYPT_MODE, privateKeyEntry.getPrivateKey());
after log privateKeyEntry.getCertificate().getPublicKey() and privateKeyEntry.getPrivateKey()
I saw the keys mModulas are equals, anyone has any idea about that?
You are using keys managed by "AndroidKeyStore" key. Try to remove "AndroidOpenSSL" here
Cipher output = Cipher.getInstance(RSA_MODE, "AndroidOpenSSL");
after log
privateKeyEntry.getCertificate().getPublicKey()
andprivateKeyEntry.getPrivateKey()
I saw the keys mModulas are equals, anyone has any idea about that?
The public modulus of the private key and the public key are the same. This is normal