keyStore rsa privateKeyEntry, public 密钥和私钥相等

keyStore rsa privateKeyEntry, public key and private key are equals

我生成了 RSA 密钥并将其存储到 android keyStore 中, 然后我生成了一个 AES 密钥并使用 RSA public-key 对其进行加密,当我想解密加密的 AES-key 时出现此错误: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());

日志后 privateKeyEntry.getCertificate().getPublicKey() 和 privateKeyEntry.getPrivateKey()

我看到键 mModulas 是相等的,有人知道吗?

您正在使用由 "AndroidKeyStore" 密钥管理的密钥。尝试在此处删除 "AndroidOpenSSL"

 Cipher output = Cipher.getInstance(RSA_MODE, "AndroidOpenSSL");

after log privateKeyEntry.getCertificate().getPublicKey() and privateKeyEntry.getPrivateKey() I saw the keys mModulas are equals, anyone has any idea about that?

私钥的public模数与public密钥相同。这很正常