module

NaCl::Util

Instance methods

check_length(collection, length, description)

Check the length of the passed in collection

In several places through the codebase we have to be VERY strict with what length of string we accept. This method supports that.

Source
prepend_zeros(n, message)

Prepends a message with zeros

Many functions require a string with some zeros prepended.

@param [Integer] n The number of zeros to prepend @param [String] message The string to be prepended

@return [String] a bunch of zeros

Source
remove_zeros(n, message)

Remove zeros from the start of a message

Many functions require a string with some zeros prepended, then need them removing after. Note: this modifies the passed in string

@param [Integer] n The number of zeros to remove @param [String] message The string to be slice

@return [String] less a bunch of zeros

Source
slice_concat(*slices)
Source
verify16(one, two)

Compare two 16 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
verify16!(one, two)

Compare two 16 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
verify32(one, two)

Compare two 32 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
verify32!(one, two)

Compare two 32 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
verify64(one, two)

Compare two 64 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
verify64!(one, two)

Compare two 64 byte strings in constant time

This should help to avoid timing attacks for string comparisons in your application. Note that many of the functions (such as HmacSha512#verify) use this method under the hood already.

Source
zero_pad(n, message)

Pad a string out to n characters with zeros

@param [Integer] n The length of the resulting string @param [String] message the message to be padded

@raise [RbNaCl::LengthError] If the string is too long

@return [String] A string, n bytes long

Source
zeros(n = 32)

Returns a string of n zeros

Lots of the functions require us to create strings to pass into functions of a specified size.

@param [Integer] n the size of the string to make

@return [String] A nice collection of zeros

Source