Class CryptoFormat


  • public final class CryptoFormat
    extends java.lang.Object
    Constants and convenience methods that deal with crypto format.
    Since:
    1.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getOutputPrefix​(com.google.crypto.tink.proto.Keyset.Key key)
      Generates the prefix of all cryptographic outputs (ciphertexts, signatures, MACs, ...) produced by the specified key.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NON_RAW_PREFIX_SIZE

        public static final int NON_RAW_PREFIX_SIZE
        Prefix size of Tink, Legacy and Crunchy output prefix types.
        See Also:
        Constant Field Values
      • LEGACY_PREFIX_SIZE

        public static final int LEGACY_PREFIX_SIZE
        Legacy or Crunchy prefix starts with \x00 and followed by a 4-byte key id.
        See Also:
        Constant Field Values
      • TINK_PREFIX_SIZE

        public static final int TINK_PREFIX_SIZE
        Tink prefix starts with \x01 and followed by a 4-byte key id.
        See Also:
        Constant Field Values
      • RAW_PREFIX_SIZE

        public static final int RAW_PREFIX_SIZE
        Raw prefix is empty.
        See Also:
        Constant Field Values
      • RAW_PREFIX

        public static final byte[] RAW_PREFIX
    • Method Detail

      • getOutputPrefix

        public static byte[] getOutputPrefix​(com.google.crypto.tink.proto.Keyset.Key key)
                                      throws java.security.GeneralSecurityException
        Generates the prefix of all cryptographic outputs (ciphertexts, signatures, MACs, ...) produced by the specified key. The prefix can be either empty (for RAW-type prefix), or consists of a 1-byte indicator of the type of the prefix, followed by 4 bytes of key.key_id in Big Endian encoding.
        Returns:
        a prefix.
        Throws:
        java.security.GeneralSecurityException - if the prefix type of key is unknown.