Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.security.key.rsa
Class RSAKeyPairX509Codec  view RSAKeyPairX509Codec download RSAKeyPairX509Codec.java

java.lang.Object
  extended bygnu.java.security.key.rsa.RSAKeyPairX509Codec
All Implemented Interfaces:
gnu.java.security.key.IKeyPairCodec

public class RSAKeyPairX509Codec
extends java.lang.Object
implements gnu.java.security.key.IKeyPairCodec

An implementation of an gnu.java.security.key.IKeyPairCodec that knows how to encode / decode X.509 ASN.1 external representation of RSA public keys.


Field Summary
private static java.util.logging.Logger log
           
private static gnu.java.security.OID RSA_ALG_OID
           
 
Fields inherited from interface gnu.java.security.key.IKeyPairCodec
ASN1_FORMAT, PKCS8_FORMAT, RAW_FORMAT, X509_FORMAT
 
Constructor Summary
RSAKeyPairX509Codec()
           
 
Method Summary
 java.security.PrivateKey decodePrivateKey(byte[] input)
          Decodes an instance of an external private key into its native Java representation.
 java.security.PublicKey decodePublicKey(byte[] input)
          Decodes an instance of an external public key into its native Java representation.
 byte[] encodePrivateKey(java.security.PrivateKey key)
          Encodes an instance of a private key for storage or transmission purposes.
 byte[] encodePublicKey(java.security.PublicKey key)
          Returns the X.509 ASN.1 SubjectPublicKeyInfo representation of an RSA public key.
 int getFormatID()
          Returns the unique identifier (within this library) of the format used to externalise public and private keys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

RSA_ALG_OID

private static final gnu.java.security.OID RSA_ALG_OID
Constructor Detail

RSAKeyPairX509Codec

public RSAKeyPairX509Codec()
Method Detail

getFormatID

public int getFormatID()
Description copied from interface: gnu.java.security.key.IKeyPairCodec

Returns the unique identifier (within this library) of the format used to externalise public and private keys.

Specified by:
getFormatID in interface gnu.java.security.key.IKeyPairCodec

encodePublicKey

public byte[] encodePublicKey(java.security.PublicKey key)
Returns the X.509 ASN.1 SubjectPublicKeyInfo representation of an RSA public key. The ASN.1 specification, as defined in RFC-3280, and RFC-2459, is as follows:
   SubjectPublicKeyInfo ::= SEQUENCE {
     algorithm         AlgorithmIdentifier,
     subjectPublicKey  BIT STRING
   }

   AlgorithmIdentifier ::= SEQUENCE {
     algorithm   OBJECT IDENTIFIER,
     parameters  ANY DEFINED BY algorithm OPTIONAL
   }
 

As indicated in RFC-2459: "The parameters field shall have ASN.1 type NULL for this algorithm identifier.".

The subjectPublicKey field, which is a BIT STRING, contains the DER-encoded form of the RSA public key defined as:

   RSAPublicKey ::= SEQUENCE {
     modulus         INTEGER, -- n
     publicExponent  INTEGER  -- e
   }
 

Specified by:
encodePublicKey in interface gnu.java.security.key.IKeyPairCodec

encodePrivateKey

public byte[] encodePrivateKey(java.security.PrivateKey key)
Description copied from interface: gnu.java.security.key.IKeyPairCodec

Encodes an instance of a private key for storage or transmission purposes.

Specified by:
encodePrivateKey in interface gnu.java.security.key.IKeyPairCodec

decodePublicKey

public java.security.PublicKey decodePublicKey(byte[] input)
Description copied from interface: gnu.java.security.key.IKeyPairCodec

Decodes an instance of an external public key into its native Java representation.

Specified by:
decodePublicKey in interface gnu.java.security.key.IKeyPairCodec

decodePrivateKey

public java.security.PrivateKey decodePrivateKey(byte[] input)
Description copied from interface: gnu.java.security.key.IKeyPairCodec

Decodes an instance of an external private key into its native Java representation.

Specified by:
decodePrivateKey in interface gnu.java.security.key.IKeyPairCodec