Next: , Previous: The KeyPairGeneratorFactory Class, Up: Keypairs


8.5 The IKeyPairCodec Interface

A key pair codec is used to externalize and de-externalize the key pairs used in GNU Crypto. There is no factory class, but rather the implementations have public, zero-argument constructors. The available codecs are:

— Variable: int RAW_FORMAT

Constant identifying the “raw” format used by GNU Crypto.

— Function: java.security.PrivateKey decodePrivateKey (byte[] encoded)

Decodes a private key from its external representation, returning it as an appropriate instance of java.security.PrivateKey. This function will throw a java.lang.IllegalArgumentException if the encoded bytes cannot be decoded or are incorrect.

— Function: java.security.PublicKey decodePublicKey (byte[] encoded)

Decodes a public key from its external representation, returning it as an appropriate instance of java.security.PublicKey. This function will throw a java.lang.IllegalArgumentException if the encoded bytes cannot be decoded or are incorrect.

— Function: byte [] encodePrivateKey (java.security.PrivateKey key)

Encodes a private key to its external representation, returning the encoded bytes. This function will throw a java.lang.IllegalArgumentException if the key cannot be encoded by this instance.

— Function: byte [] encodePublicKey (java.security.PublicKey key)

Encodes a public key to its external representation, returning the encoded bytes. This function will throw a java.lang.IllegalArgumentException if the key cannot be encoded by this instance.

— Function: int getFormatID ()

Returns the format identifier of this codec, such as RAW_FORMAT.