class RbNaCl::Hash::Blake2b

def self.validate_opts(opts)

Returns:
  • (Hash) - opts Configuration hash with sanitized values

Raises:
  • (RbNaCl::LengthError) - Invalid length specified for one or more options

Options Hash: (**opts)
  • :personal (Personal) -- Provide personalisation string to allow pinning a hash for a particular purpose.
  • :salt (String) -- Provide a salt to support randomised hashing.
  • :digest_size (Integer) -- size of output digest in bytes
  • :key (String) -- for Blake2b keyed mode

Parameters:
  • options (Hash) -- Blake2b configuration
def self.validate_opts(opts)
  key = opts.fetch(:key, nil)
  if key
    key_size = key.bytesize
    raise LengthError, "key too short" if key_size < KEYBYTES_MIN
    raise LengthError, "key too long"  if key_size > KEYBYTES_MAX
  else
    key_size = 0
  end
  opts[:key_size] = key_size
  digest_size = opts.fetch(:digest_size, BYTES_MAX)
  raise LengthError, "digest size too short" if digest_size < BYTES_MIN
  raise LengthError, "digest size too long"  if digest_size > BYTES_MAX
  opts[:digest_size] = digest_size
  personal = opts.fetch(:personal, EMPTY_PERSONAL)
  opts[:personal] = Util.zero_pad(PERSONALBYTES, personal)
  salt = opts.fetch(:salt, EMPTY_SALT)
  opts[:salt] = Util.zero_pad(SALTBYTES, salt)
  opts
end