util/++ util/= util/bin2hex util/compare util/hex2bin util/memzero util/pad util/unpad
(util/++ buffer)
Increment a buffer, treating it as a little endian large integer. If the increment results in an overflow, sets the buffer to all zero bytes. Returns the modified buffer.
(util/= lhs rhs)
Compare the contents of two equal length buffers without early returns, which helps prevent side channel attacks. This is the function that should be used for comparing two buffers with cryptographic content. If the two buffers are of different lengths, returns early. Returns a boolen.
(util/bin2hex bin &opt hex)
Convert binary data into hexidecimal. The hex representation of bin, the input buffer, is converted to a ascii hexidecimal and put in the buffer hex, or a new buffer if hex is not supplied. Returns hex or a new buffer.
(util/compare lhs rhs)
Compare two buffers without early returns to help prevent side channel attacks. Returns an integer -1, 0, or 1.
(util/hex2bin hex &opt bin ignore)
Convert a hexidecimal string to binary data. Can provide an optional bin to write into instead of creating a new buffer, and also a string of characters to ignore while reading hex. Returns the buffer bin or a new buffer.
(util/memzero buffer)
Clear memory in a buffer to 0, not changing the size of the buffer. Returns the modified buffer.
(util/pad buffer blocksize)
Pad a buffer according to the ISO/IEC 7816-4 algorithm. Returns the modified buffer.
(util/unpad buffer blocksize)
Unpad a buffer padded via util/pad. Returns the modifed buffer.