| Prev Class | Next Class | Frames | No Frames |
| Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Objectgnu.javax.crypto.key.dh.DHKeyPairX509CodecFields inherited from interface gnu.java.security.key.IKeyPairCodec | |
ASN1_FORMAT, PKCS8_FORMAT, RAW_FORMAT, X509_FORMAT | |
Method Summary | |
PrivateKey |
|
PublicKey |
|
byte[] | |
byte[] |
|
int | |
Methods inherited from class java.lang.Object | |
clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait | |
public PrivateKey decodePrivateKey(byte[] input)
- Specified by:
- decodePrivateKey in interface IKeyPairCodec
- Throws:
InvalidParameterException- ALWAYS.
public PublicKey decodePublicKey(byte[] input)
- Specified by:
- decodePublicKey in interface IKeyPairCodec
- Parameters:
input- the byte array to unmarshall into a valid DHPublicKeyinstance. MUST NOT be null.
- Returns:
- a new instance of a
GnuDHPublicKeydecoded from the SubjectPublicKeyInfo material in an X.509 certificate.
public byte[] encodePrivateKey(PrivateKey key)
- Specified by:
- encodePrivateKey in interface IKeyPairCodec
- Throws:
InvalidParameterException- ALWAYS.
public byte[] encodePublicKey(PublicKey key)
Returns the DER-encoded form of the X.509 ASN.1 SubjectPublicKeyInfo representation of a DH 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 } DhParams ::= SEQUENCE { p INTEGER, -- odd prime, p=jq +1 g INTEGER, -- generator, g q INTEGER -- factor of p-1 }The subjectPublicKey field, which is a BIT STRING, contains the DER-encoded form of the DH public key as an INTEGER.DHPublicKey ::= INTEGER -- public key, y = g^x mod pIMPORTANT: with RI'sDHGenParameterSpecandDHParameterSpecclasses, we may end up with Diffie-Hellman keys that have anullfor theqparameter. RFC-2631 DOES NOT allow for an optional value for that parameter, hence we replace such null values with0, and do the reverse in the corresponding decode method.
- Specified by:
- encodePublicKey in interface IKeyPairCodec
- Parameters:
key- thePublicKeyinstance to encode. MUST be an instance ofGnuDHPublicKey.
- Returns:
- the DER-encoded form of the ASN.1 representation of the SubjectPublicKeyInfo in an X.509 certificate.