libsodium-bindings
Copyright(C) Koz Ross 2022 Jack Henahan 2025
LicenseBSD-3-Clause
Maintainerkoz.ross@retro-freedom.nz
StabilityStable
PortabilityGHC only
Safe HaskellTrustworthy
LanguageHaskell2010

LibSodium.Bindings.Comparison

Description

Secure comparison functions, designed to run in constant time for a given input length.

Synopsis

Documentation

sodiumMemcmp Source #

Arguments

:: Ptr CUChar

First location with data to compare

-> Ptr CUChar

Second location with data to compare

-> CSize

How many bytes to compare

-> CInt

0 if all bytes match, -1 otherwise

Compares the given amount of bytes at the given locations for equality. Constant-time for any given length.

See: sodium_memcmp()

Since: 0.0.1.0

sodiumCompare Source #

Arguments

:: Ptr CUChar

First pointer data (lhs)

-> Ptr CUChar

Second pointer data (rhs)

-> CSize

Bytes to compare

-> IO CInt

Comparison result lhs == rhs -> 0 lhs - -1 lhs > rhs -> 1

Lexicographically compares the requested bytes of the given pointers in constant time.

See: sodium_compare()

Since: 0.0.3.0

sodiumIsZero Source #

Arguments

:: Ptr CUChar

Location with data to check

-> CSize

How many bytes to check

-> CInt

1 if all the bytes were zeroes, 0 otherwise

Checks if the given number of bytes at the given location are all equal to zero. Constant-time for any given length.

See: sodium_is_zero()

Since: 0.0.1.0