libsodium_crypto_verify_32 (libsodium v3.0.1)

View Source

Constant-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

Types

x()

A crypto_verify_32_BYTES (32-byte) binary.

y()

A crypto_verify_32_BYTES (32-byte) binary.

Functions

Return crypto_verify_32_bytes(), in bytes.

Compare X and Y in constant time; returns 0 when they are equal and -1 otherwise.

Types

x()

-type x() :: <<_:256>>.

A crypto_verify_32_BYTES (32-byte) binary.

y()

-type y() :: <<_:256>>.

A crypto_verify_32_BYTES (32-byte) binary.

Functions

bytes()

-spec bytes() -> Result when Result :: 32.

Return crypto_verify_32_bytes(), in bytes.

crypto_verify_32(X, Y)

-spec crypto_verify_32(X, Y) -> Result when X :: x(), Y :: y(), Result :: 0 | -1.

Compare X and Y in constant time; returns 0 when they are equal and -1 otherwise.