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

RE: [iaik-jce] saving and reading private key to/from file



Hi !

Here is a possible solution for your problem (modulo exception / error
handling)
You'll get a byte array which you can write into a file.


	KeyFactory kf = KeyFactory.getInstance( privateKey instanceof
RSAPrivateKey ? "RSA" : "DSA" );
	byte[] pkcs8EncodedKey;

	pkcs8EncodedKey = ((PKCS8EncodedKeySpec)kf.getKeySpec(privateKey,
PKCS8EncodedKeySpec.class)).getEncoded();


andi

> -----Original Message-----
> From: Ronen Lazar [mailto:RonenL@gilian.com]
> Sent: Montag, 18. Dezember 2000 20:03
> To: 'iaik-jce@iaik.tu-graz.ac.at'
> Subject: [iaik-jce] saving and reading private key to/from file
> 
> 
> Hello good people,
> 
> Once I've created a private key (say DSA or RSA), I'd like to 
> be able to
> store it in a file, and than be able to restore it into a 
> PrivateKey object.
> 
> How can that be done?
> I thought using DsaPrivateKey (for DSA private key) could be 
> the answer, but
> its decode()/encode() methods are protected, so I doubt it's the right
> direction.
> 
> Any help would be most appreciated.
> 
> TIA,
> Ronen.
> --
> Mailinglist-archive at 
> http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html
> 
> To unsubscribe send an email to listserv@iaik.at with the 
> folowing content: UNSUBSCRIBE iaik-jce
>  
> 
--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-jce/jcethreads.html

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