[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iaik-jce] PrivateKey Interpretation problem

>I am trying to read the RSAPrivateKey generated by Eric Young's SSLeay
>library from IAIK_JCE and it gives me the following error:

>"Unable to decode private key: java.security.InvalidKeyException: Can't
>parse PublicKeyInfo."

SSLeay saves private keys in a DER encoded PKCS-1 RSAPrivateKey structure,
not a DER encoded PKCS-8 PrivateKeyInfo structure. If the private key is
encrypted it is done so according to PEM rules, not PKCS-8 rules.

To create a Java private key from an SSLeay saved private key, you must
decrypt the key data (if necessary), parse the DER encoding to get the 8
INTEGER values and use them to create an RSAPrivateCrtKeySpec. Then pass
that into an RSA key factory with generatePrivate().

A question: why is IAIK trying to parse a PublicKeyInfo structure if you're
trying to decode a private key?

David Taylor
FORGE Research.

Mailinglist-archive at http://jcewww.iaik.tu-graz.ac.at/mailarchive/iaik-jce/maillist.html

To unsubscribe send an email to listserv@iaik.tu-graz.ac.at with the folowing content: UNSUBSCRIBE iaik-jce