Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to read Cipher private Key with bouncycastle in android?
    primarykey
    data
    text
    <p>I have a private key that encrypted with <code>AES256</code> and key <code>salam</code>.</p> <p>I want to decrypt it and read the private key in that.</p> <p>I Write Below Code :</p> <pre><code>public CertReader(String password, Context context) { mContext = context; pf = new Password(password.toCharArray()); InputStream Certin = mContext.getResources().openRawResource( R.raw.kxx_2048_sign); PEMReader pemRd = openPEMResource(Certin, pf); Object o = null; try { o = pemRd.readObject(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } X509Certificate x509 = ((X509Certificate) o); logging.l(x509.toString()); Certin = mContext.getResources().openRawResource( R.raw.kxx_2048); pemRd = openPEMResource(Certin, pf); try { o = pemRd.readObject(); //My Program exit with error here. } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // KeyPair key = ((KeyPair)o); // logging.l(key.toString()); } private PEMReader openPEMResource(InputStream Certin, PasswordFinder pGet) { Reader fRd = new BufferedReader(new InputStreamReader(Certin)); return new PEMReader(fRd, pGet); } private static class Password implements PasswordFinder { char[] password; Password(char[] word) { this.password = word; } public char[] getPassword() { return password; } } </code></pre> <p><code>kxx_2048_sign.crt</code> is a Certificate and there is no problem with it because it is not encrypt.</p> <p>but <code>kxx_2048.key</code> is encrypted with <code>AES256</code> and in <code>o = pemRd.readObject();</code> i got below error :</p> <pre><code> java.lang.IllegalAccessError: tried to access class org.bouncycastle.openssl.PEMUtilities from class org.bouncycastle.openssl.PEMReader$KeyPairParser </code></pre> <p>key start with this:</p> <pre><code>-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-256-CBC,5C76FCD87..... </code></pre> <p>What is the problem?</p> <p>I checked it on PC and it worked Correct but in Android it does not work.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload