public class RSAKeyPairRawCodec extends java.lang.Object implements IKeyPairCodec
An object that implements the IKeyPairCodec interface for the
Raw format to use with RSA keypairs.
RAW_FORMAT, X509_FORMAT| Constructor and Description |
|---|
RSAKeyPairRawCodec() |
| Modifier and Type | Method and Description |
|---|---|
java.security.PrivateKey |
decodePrivateKey(byte[] k)
Decodes an instance of an external private key into its native Java
representation.
|
java.security.PublicKey |
decodePublicKey(byte[] k)
Decodes an instance of an external public key into its native Java
representation.
|
byte[] |
encodePrivateKey(java.security.PrivateKey key)
Returns the encoded form of the designated RSA private key according to
the Raw format supported by this library.
|
byte[] |
encodePublicKey(java.security.PublicKey key)
Returns the encoded form of the designated RSA public key according to
the Raw format supported by this library.
|
int |
getFormatID()
Returns the unique identifier (within this library) of the format used
to externalise public and private keys.
|
public int getFormatID()
IKeyPairCodecReturns the unique identifier (within this library) of the format used to externalise public and private keys.
getFormatID in interface IKeyPairCodecpublic byte[] encodePublicKey(java.security.PublicKey key)
Returns the encoded form of the designated RSA public key according to the Raw format supported by this library.
The Raw format for an RSA public key, in this implementation, is a byte sequence consisting of the following:
Registry.MAGIC_RAW_RSA_PUBLIC_KEY,n (the modulus) in internet order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter n,e (the public exponent) in internet order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter e.encodePublicKey in interface IKeyPairCodeckey - the key to encode.java.lang.IllegalArgumentException - if the designated key is not an RSA
one.public java.security.PublicKey decodePublicKey(byte[] k)
IKeyPairCodecDecodes an instance of an external public key into its native Java representation.
decodePublicKey in interface IKeyPairCodeck - the source of the externalised key to decode.public byte[] encodePrivateKey(java.security.PrivateKey key)
Returns the encoded form of the designated RSA private key according to the Raw format supported by this library.
The Raw format for an RSA private key, in this implementation, is a byte sequence consisting of the following:
Registry.MAGIC_RAW_RSA_PRIVATE_KEY,p (the first prime factor of the modulus) in internet
order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter p,q (the second prime factor of the modulus) in internet
order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter q,e (the public exponent) in internet order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter e,d (the private exponent) in internet order,BigInteger obtained by invoking
the toByteArray() method on the RSA parameter d,encodePrivateKey in interface IKeyPairCodeckey - the key to encode.public java.security.PrivateKey decodePrivateKey(byte[] k)
IKeyPairCodecDecodes an instance of an external private key into its native Java representation.
decodePrivateKey in interface IKeyPairCodeck - the source of the externalised key to decode.Copyright © 2025. All rights reserved.