module NaCl::Util
Extended Modules
Defined in:
nacl/util.crInstance Method Summary
-
#check_length(collection, length, description)
Check the length of the passed in collection
-
#prepend_zeros(n, message)
Prepends a message with zeros
-
#remove_zeros(n, message)
Remove zeros from the start of a message
- #slice_concat(*slices)
-
#verify16(one, two)
Compare two 16 byte strings in constant time
-
#verify16!(one, two)
Compare two 16 byte strings in constant time
-
#verify32(one, two)
Compare two 32 byte strings in constant time
-
#verify32!(one, two)
Compare two 32 byte strings in constant time
-
#verify64(one, two)
Compare two 64 byte strings in constant time
-
#verify64!(one, two)
Compare two 64 byte strings in constant time
-
#zero_pad(n, message)
Pad a string out to n characters with zeros
-
#zeros(n = 32)
Returns a string of n zeros
Instance Method Detail
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.
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
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
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.
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.
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.
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.
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.
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.
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
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