Class LegacyKeysetSerialization

    • Method Detail

      • parseKeysetWithoutSecret

        public static KeysetHandle parseKeysetWithoutSecret​(KeysetReader reader)
                                                     throws java.security.GeneralSecurityException,
                                                            java.io.IOException
        Parse a KeysetHandle from the reader.

        This method is used for keysets containing no secret key material.

        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • parseKeyset

        public static KeysetHandle parseKeyset​(KeysetReader reader,
                                               SecretKeyAccess access)
                                        throws java.security.GeneralSecurityException,
                                               java.io.IOException
        Parse a keyset from the reader.

        This is used to parse keysets that may contain secret key material. The second argument has to be InsecureSecretKeyAccess.get().

        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • parseEncryptedKeyset

        public static KeysetHandle parseEncryptedKeyset​(KeysetReader reader,
                                                        Aead aead,
                                                        byte[] associatedData)
                                                 throws java.security.GeneralSecurityException,
                                                        java.io.IOException
        Parse an encrypted keyset from the reader.
        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • serializeKeysetWithoutSecret

        public static void serializeKeysetWithoutSecret​(KeysetHandle keysetHandle,
                                                        KeysetWriter writer)
                                                 throws java.security.GeneralSecurityException,
                                                        java.io.IOException
        Serialize a keyset to the writer.

        This method is used for keysets containing no secret key material.

        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • serializeKeyset

        public static void serializeKeyset​(KeysetHandle keysetHandle,
                                           KeysetWriter writer,
                                           SecretKeyAccess access)
                                    throws java.io.IOException
        Serialize a keyset to the writer.

        This method is used to serialize keysets that may contain secret key material. The last argument must be InsecureSecretKeyAccess.get().

        Throws:
        java.io.IOException
      • serializeEncryptedKeyset

        public static void serializeEncryptedKeyset​(KeysetHandle keysetHandle,
                                                    KeysetWriter writer,
                                                    Aead aead,
                                                    byte[] associatedData)
                                             throws java.security.GeneralSecurityException,
                                                    java.io.IOException
        Serialize a keyset in an encrypted format to the writer.
        Throws:
        java.security.GeneralSecurityException
        java.io.IOException
      • getKeysetInfo

        public static com.google.crypto.tink.proto.KeysetInfo getKeysetInfo​(KeysetHandle handle)
        Returns the KeysetInfo proto of the given KeysetHandle.

        Note: in most cases you can get more information by calling handle.getAt(i).getKey() and casting the result to the appropriate key type.