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

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



Every key has a getEncoded() method, the simplest solution is to use that.
Anyway, storing private keys without encryption is not recommended, use the
KeyStore or PKCS#12 classes for that.

Regarding JDK 1.1 vs. JDK 1.2, all relevant JDK 1.2 classes are also
available under JDK 1.1 with the IAIK JCE, that is what the
jdk11x_update.jar is for.

 Andreas Sterbenz              mailto:Andreas.Sterbenz@iaik.at


----- Original Message -----
From: "Ronen Lazar" <RonenL@gilian.com>
To: <iaik-jce@iaik.tu-graz.ac.at>
Sent: Tuesday, December 19, 2000 10:03 AM
Subject: RE: [iaik-jce] saving and reading private key to/from file


> Forgot to mention that I use *JDK1.1.8*, and thus I can't use
> these wonderful classes (which belong to jdk1.2)...
>
> Any idea?
>
> -----Original Message-----
> From: Hiltenkamp, Andreas [mailto:Andreas.Hiltenkamp@healy-hudson.com]
> Sent: Tuesday, December 19, 2000 9:15 AM
> To: 'iaik-jce@iaik.tu-graz.ac.at'
> Cc: 'Ronen Lazar'
> Subject: 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();


--
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