Class Generator


  • public class Generator
    extends java.lang.Object
    Utility class that generates secure random byte arrays.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int BLOCK_SIZE
      Should be 16 for AES256 the same as the iv.
      static int CHUNK_SIZE_LENGTH
      Chunk size format length.
      static int HASH_KEY_LENGTH
      HASH Key length for integrity, currently we use HMAC SHA256.
      static int HASH_RESULT_LENGTH
      Hash signature size for integrity, currently we use HMAC SHA256.
      static int KEY_LENGTH
      Encryption key length for AES256.
      static int MAGIC_LENGTH
      Lenght for the magic bytes.
      static int NONCE_LENGTH
      Nonce size.
      static byte VERSION
      Version.
      static int VERSION_LENGTH
      Length for the Version in the data header.
    • Constructor Summary

      Constructors 
      Constructor Description
      Generator()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] getMagicBytes()
      Gets the fixed magic bytes array
      static byte[] getSecureRandomBytes​(int size)
      Returns a secure random byte array.
      static byte getVersion()
      Returns the current Salmon format version.
      • Methods inherited from class java.lang.Object

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

      • MAGIC_LENGTH

        public static final int MAGIC_LENGTH
        Lenght for the magic bytes.
        See Also:
        Constant Field Values
      • VERSION_LENGTH

        public static final int VERSION_LENGTH
        Length for the Version in the data header.
        See Also:
        Constant Field Values
      • BLOCK_SIZE

        public static final int BLOCK_SIZE
        Should be 16 for AES256 the same as the iv.
        See Also:
        Constant Field Values
      • KEY_LENGTH

        public static final int KEY_LENGTH
        Encryption key length for AES256.
        See Also:
        Constant Field Values
      • HASH_KEY_LENGTH

        public static final int HASH_KEY_LENGTH
        HASH Key length for integrity, currently we use HMAC SHA256.
        See Also:
        Constant Field Values
      • HASH_RESULT_LENGTH

        public static final int HASH_RESULT_LENGTH
        Hash signature size for integrity, currently we use HMAC SHA256.
        See Also:
        Constant Field Values
      • CHUNK_SIZE_LENGTH

        public static final int CHUNK_SIZE_LENGTH
        Chunk size format length.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Generator

        public Generator()
    • Method Detail

      • getMagicBytes

        public static byte[] getMagicBytes()
        Gets the fixed magic bytes array
        Returns:
        The magic bytes
      • getVersion

        public static byte getVersion()
        Returns the current Salmon format version.
        Returns:
        The version number
      • getSecureRandomBytes

        public static byte[] getSecureRandomBytes​(int size)
        Returns a secure random byte array. To be used when generating keys, initial vectors, and nonces.
        Parameters:
        size - The size of the byte array.
        Returns:
        The random secure byte array.