public interface IKeyPairCodec
The visible methods of an object that knows how to encode and decode cryptographic asymmetric keypairs. Codecs are useful for (a) externalising public and private keys for storage and on-the-wire transmission, as well as (b) re-creating their internal Java representation from external sources.
Modifier and Type | Field and Description |
---|---|
static int |
RAW_FORMAT
Constant identifying the Raw encoding format.
|
static int |
X509_FORMAT |
Modifier and Type | Method and Description |
---|---|
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)
Encodes an instance of a public key for storage or transmission purposes.
|
int |
getFormatID()
Returns the unique identifier (within this library) of the format used
to externalise public and private keys.
|
static final int RAW_FORMAT
static final int X509_FORMAT
int getFormatID()
Returns the unique identifier (within this library) of the format used to externalise public and private keys.
byte[] encodePublicKey(java.security.PublicKey key)
Encodes an instance of a public key for storage or transmission purposes.
key
- the non-null key to encode.java.lang.IllegalArgumentException
- if the designated key is not supported
by this codec.byte[] encodePrivateKey(java.security.PrivateKey key)
Encodes an instance of a private key for storage or transmission purposes.
key
- the non-null key to encode.java.lang.IllegalArgumentException
- if the designated key is not supported
by this codec.java.security.PublicKey decodePublicKey(byte[] input)
Decodes an instance of an external public key into its native Java representation.
input
- the source of the externalised key to decode.java.lang.IllegalArgumentException
- if the designated input does not
contain a known representation of a public key for the format supported by
the concrete codec.java.security.PrivateKey decodePrivateKey(byte[] input)
Decodes an instance of an external private key into its native Java representation.
input
- the source of the externalised key to decode.java.lang.IllegalArgumentException
- if the designated input does not
contain a known representation of a private key for the format supported
by the concrete codec.Copyright © 2025. All rights reserved.