X509EncodedKeySpec
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, August 26, 2002 04:23 AM

Hi, The following is from the API. public class X509EncodedKeySpec extends EncodedKeySpec This class represents the ASN.1 encoding of a public key, encoded according to the ASN.1 type SubjectPublicKeyInfo. public abstract class EncodedKeySpec extends Object implements KeySpec This class represents a public or private key in encoded format. Does this mean that X509EncodedKeySpec cannot be used to read bytes of a private key like byte[] encKey = ...... X509EncodedKeySpec priKeySpec = new X509EncodedKeySpec( encKey ); KeyFactory kf = KeyFactory.getInstance( "DSA", "SUN" ); privateKey_ = kf.generateP   More>>

Hi,


The following is from the API.

			
public class X509EncodedKeySpec extends EncodedKeySpec
This class represents the ASN.1 encoding of a public key, encoded according to the ASN.1 type SubjectPublicKeyInfo.

public abstract class EncodedKeySpec
extends Object
implements KeySpec
This class represents a public or private key in encoded format.


Does this mean that X509EncodedKeySpec cannot be used to read bytes of a private key like

			
byte[] encKey = ......
X509EncodedKeySpec priKeySpec = new X509EncodedKeySpec( encKey );
KeyFactory kf = KeyFactory.getInstance( "DSA", "SUN" );
privateKey_ = kf.generatePrivate( priKeySpec );


bye,

Mohan    <<Less

Re: X509EncodedKeySpec

Posted By:   Sean_Reilly  
Posted On:   Wednesday, August 28, 2002 09:12 PM

Yes, X509 is used for encoding certificates that contain public keys. Since private keys don't go into certificates, they are generally stored in whatever format is appropriate (usually PKCS) for the type of key (usually RSA or DSA).


You might want to check into something like PKCS8EncodedKeySpec for reading/writing private keys.

About | Sitemap | Contact