public class KeySerializationHelper
extends java.lang.Object
Constructor and Description |
---|
KeySerializationHelper() |
Modifier and Type | Method and Description |
---|---|
static java.security.KeyPair |
deserializeAsymKeyPair(byte[] publicKeyData,
byte[] privateKeyData,
char[] protectPassphrase,
java.security.KeyFactory keyFactory)
Method to deserialize an asymmetric key data into a key pair.
|
static java.security.KeyPair |
deserializeBTCPayServerKeyPair(byte[] privateKeyData,
char[] protectPassphrase,
java.security.KeyFactory keyFactory,
java.lang.String eCCurveName)
Method to deserialize an BTC Pay Server key data into a key pair.
|
static java.security.PublicKey |
deserializePublicKey(byte[] publicKeyData,
java.security.KeyFactory keyFactory)
Help method to decode a public key data only.
|
static java.security.Key |
deserializeSecretKey(byte[] data,
char[] protectPassphrase)
Method to deserialize key data of a secret key.
|
static java.lang.String |
genKeyId(byte[] keyData)
Help method to generate a keyId of a specific key used to identify it.
|
static byte[][] |
serializeAsymKeyPair(java.security.KeyPair keyPair,
char[] protectPassphrase)
Method to serialize an asymmetric key pair to key data.
|
static byte[][] |
serializeBTCPayServerKeyPair(java.security.KeyPair keyPair,
char[] protectPassphrase)
Method to serialize an btc pay server access token key pair to key data.
|
static byte[] |
serializeSecretKey(java.security.Key key,
char[] protectPasshrase)
Method to serialize a secret key to key data.
|
public static byte[] serializeSecretKey(java.security.Key key, char[] protectPasshrase) throws InternalErrorException
key
- the secret key to serialize, never null.protectPasshrase
- the password protecting the key.InternalErrorException
- if internal problems occurred serializing the key.public static java.security.Key deserializeSecretKey(byte[] data, char[] protectPassphrase) throws InternalErrorException
data
- the serialized key data.protectPassphrase
- the password protecting the key.InternalErrorException
- if problems occurred deserializing the secret key.public static byte[][] serializeAsymKeyPair(java.security.KeyPair keyPair, char[] protectPassphrase) throws InternalErrorException
keyPair
- the key pair to serialize, never null.protectPassphrase
- the password used to protect the private key.InternalErrorException
- if internal problems occurred serializing the keys.public static byte[][] serializeBTCPayServerKeyPair(java.security.KeyPair keyPair, char[] protectPassphrase) throws InternalErrorException
keyPair
- the key pair to serialize, never null.protectPassphrase
- the password used to protect the private key.InternalErrorException
- if internal problems occurred serializing the keys.public static java.security.KeyPair deserializeAsymKeyPair(byte[] publicKeyData, byte[] privateKeyData, char[] protectPassphrase, java.security.KeyFactory keyFactory) throws InternalErrorException
publicKeyData
- the serialized public key data, never null.privateKeyData
- the serialized private key data, never null.protectPassphrase
- the password protecting the key.keyFactory
- the keyFactory to reconstruct the keys with.InternalErrorException
- if internal problems occurred deserializing the keys.public static java.security.KeyPair deserializeBTCPayServerKeyPair(byte[] privateKeyData, char[] protectPassphrase, java.security.KeyFactory keyFactory, java.lang.String eCCurveName) throws InternalErrorException
privateKeyData
- the serialized private key data, never null.protectPassphrase
- the password protecting the key.keyFactory
- the keyFactory to reconstruct the keys with.eCCurveName
- the name of used ec curve.InternalErrorException
- if internal problems occurred deserializing the keys.public static java.security.PublicKey deserializePublicKey(byte[] publicKeyData, java.security.KeyFactory keyFactory) throws InternalErrorException
publicKeyData
- the public key data to parse.keyFactory
- the keyFactory to reconstruct the keys with.InternalErrorException
- if internal problems occurred deserializing the keys.public static java.lang.String genKeyId(byte[] keyData) throws InternalErrorException
keyData
- the keyData.InternalErrorException
- if internal error occurred generating the digest of the keyData.