libsodium_crypto_verify_32 (libsodium v3.0.1)
View SourceConstant-time comparison of two bytes/0 (32) byte secrets, such as
authentication tags, whose timing does not depend on where they differ.
Returns 0 when the binaries are equal and -1 otherwise. Both arguments
must be exactly bytes/0 bytes long.
Tag = libsodium_randombytes:buf(libsodium_crypto_verify_32:bytes()),
0 = libsodium_crypto_verify_32:crypto_verify_32(Tag, Tag),
<<First, Rest/binary>> = Tag,
-1 = libsodium_crypto_verify_32:crypto_verify_32(Tag, <<(First bxor 1), Rest/binary>>).
Summary
Functions
Return crypto_verify_32_bytes(), in bytes.
Compare X and Y in constant time; returns 0 when they are equal and -1 otherwise.