Comparing large numbers.
Testing for all zeros.
Constant-time test for equality
Zeroing memory.
Adding large numbers
Hexadecimal encoding. The sodium_bin2hex() function converts the bytes stored at bin into a hexadecimal string.
Comparing large numbers.
Hexadecimal decoding. The sodium_hex2bin() function parses a hexadecimal string hex and converts it to a byte sequence bin. ignore_nullterminated is a string of characters to skip. ignore_nullterminated's last character MUST be '\0' in order to save allocating a new C string and thus be @nogc For example, the string ": \0" allows colons and spaces to be present at any locations in the hexadecimal string. These characters will just be ignored. As a result, "69:FC", "69 FC", "69 : FC" and "69FC" will be valid inputs, and will produce the same output. ignore_nullterminated can be set to null in order to disallow any non-hexadecimal character. bin.length is the maximum number of bytes to put into bin, thus bin has to be sized appropriately in advance as >= hex.length/2, otherwise the function throws. The parser stops when a non-hexadecimal, non-ignored character is found or when bin.length bytes have been written. bin_len is the number of bytes that actually got written into bin. @returns always true (success) and sets pos_hex_non_parsed to the position within hex following the last parsed character. It evaluates in constant time for a given length and format.
Incrementing large numbers. The sodium_increment() function takes an ubyte array representing an arbitrary-long unsigned number, and increments it. It runs in constant-time for a given length, and considers the number to be encoded in little- endian format. sodium_increment() can be used to increment nonces in constant time. This function was introduced in libsodium 1.0.4. Does nothing if the array is null
Testing for all zeros.
Constant-time test for equality
Zeroing memory.
Substracting large numbers The sodium_sub() function accepts two arrays of unsigned numbers encoded in little- endian format, a and b, both of size len bytes. It computes (a - b) mod 2^(8*len) in constant time for a given length, and overwrites a with the result.
Utility functions and unittests.