Class KeySerializer

java.lang.Object
google.registry.keyring.api.KeySerializer

public final class KeySerializer extends Object
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 Details

    • serializePublicKey

      public static byte[] serializePublicKey(org.bouncycastle.openpgp.PGPPublicKey publicKey) throws IOException
      Serialize a PGPPublicKey

      The reason we're not using PGPPublicKey.getEncoded() is to use ArmoredOutputStream.

      Throws:
      IOException
    • deserializePublicKey

      public static org.bouncycastle.openpgp.PGPPublicKey deserializePublicKey(byte[] serialized) throws IOException
      Deserialize a PGPPublicKey
      Throws:
      IOException
    • serializeString

      public static byte[] serializeString(String key)
      Serializes a string
    • deserializeString

      public static String deserializeString(byte[] serialized)
      Deserializes a string
    • serializeKeyPair

      public static byte[] serializeKeyPair(org.bouncycastle.openpgp.PGPKeyPair keyPair) throws IOException, org.bouncycastle.openpgp.PGPException
      Serialize a PGPKeyPair

      Use 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