Crash casting AndroidKeyStoreRSAPrivateKey to RSAPrivateKey

前端 未结 4 1578
误落风尘
误落风尘 2020-12-04 19:34

I\'m following this tutorial: How to use the Android Keystore to store passwords and other sensitive information. It (loosely) ties up with the Google Sample app: BasicAndro

4条回答
  •  温柔的废话
    2020-12-04 20:08

    I managed to get this working by removing the Provider from Cipher.getInstance and not casting to a RSAprivateKey.

    KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) entry;
    
    Cipher output = Cipher.getInstance("RSA/ECB/PKCS1Padding");
    output.init(Cipher.DECRYPT_MODE, privateKeyEntry.getPrivateKey());
    

    I'm not 100% but I think the reason for this I believe is the change in marshmallow from OpenSSL to BoringSSL. https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

    Anyway, the above worked for M and below.

提交回复
热议问题