Class SecretBytes


  • @Immutable
    public final class SecretBytes
    extends java.lang.Object
    A class storing an immutable byte array, protecting the data via SecretKeyAccess.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static SecretBytes copyFrom​(byte[] value, SecretKeyAccess access)
      Creates a new SecretBytes with the contents given in value.
      boolean equalsSecretBytes​(SecretBytes other)
      Returns true if the other byte array has the same bytes, in time depending only on the length of both SecretBytes objects.
      static SecretBytes randomBytes​(int length)
      Creates a new SecretBytes with bytes chosen uniformly at random of length length.
      int size()
      Returns the length of the bytes wrapped by this object.
      byte[] toByteArray​(SecretKeyAccess access)
      Returns a copy of the bytes wrapped by this object.
      • Methods inherited from class java.lang.Object

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

      • copyFrom

        public static SecretBytes copyFrom​(byte[] value,
                                           SecretKeyAccess access)
        Creates a new SecretBytes with the contents given in value.

        The parameter access must be non-null.

      • randomBytes

        public static SecretBytes randomBytes​(int length)
        Creates a new SecretBytes with bytes chosen uniformly at random of length length.
      • toByteArray

        public byte[] toByteArray​(SecretKeyAccess access)
        Returns a copy of the bytes wrapped by this object.

        The parameter access must be non-null.

      • size

        public int size()
        Returns the length of the bytes wrapped by this object.
      • equalsSecretBytes

        public boolean equalsSecretBytes​(SecretBytes other)
        Returns true if the other byte array has the same bytes, in time depending only on the length of both SecretBytes objects.