Package google.registry.keyring.api
Class KeySerializer
java.lang.Object
google.registry.keyring.api.KeySerializer
Collection of tools to serialize / deserialize PGP types.
There is no way to serialize / deserialize a PGPPrivateKey on its own, you have to pair it with the public key.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.bouncycastle.openpgp.PGPKeyPair
deserializeKeyPair
(byte[] serialized) Deserialize a PGPKeyPairstatic org.bouncycastle.openpgp.PGPPublicKey
deserializePublicKey
(byte[] serialized) Deserialize a PGPPublicKeystatic String
deserializeString
(byte[] serialized) Deserializes a stringstatic byte[]
serializeKeyPair
(org.bouncycastle.openpgp.PGPKeyPair keyPair) Serialize a PGPKeyPairstatic byte[]
serializePublicKey
(org.bouncycastle.openpgp.PGPPublicKey publicKey) Serialize a PGPPublicKeystatic byte[]
serializeString
(String key) Serializes a string
-
Method Details
-
serializePublicKey
public static byte[] serializePublicKey(org.bouncycastle.openpgp.PGPPublicKey publicKey) throws IOException Serialize a PGPPublicKeyThe reason we're not using
PGPPublicKey.getEncoded()
is to useArmoredOutputStream
.- Throws:
IOException
-
deserializePublicKey
public static org.bouncycastle.openpgp.PGPPublicKey deserializePublicKey(byte[] serialized) throws IOException Deserialize a PGPPublicKey- Throws:
IOException
-
serializeString
Serializes a string -
deserializeString
Deserializes a string -
serializeKeyPair
public static byte[] serializeKeyPair(org.bouncycastle.openpgp.PGPKeyPair keyPair) throws IOException, org.bouncycastle.openpgp.PGPException Serialize a PGPKeyPairUse this to serialize a PGPPrivateKey as well (pairing it with the corresponding PGPPublicKey), as private keys can't be serialized on their own.
- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-
deserializeKeyPair
public static org.bouncycastle.openpgp.PGPKeyPair deserializeKeyPair(byte[] serialized) throws IOException, org.bouncycastle.openpgp.PGPException Deserialize a PGPKeyPair- Throws:
IOException
org.bouncycastle.openpgp.PGPException
-