| Copyright | (C) Koz Ross 2022 Jack Henahan 2025 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | koz.ross@retro-freedom.nz |
| Stability | Stable |
| Portability | GHC only |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
LibSodium.Bindings.Comparison
Description
Secure comparison functions, designed to run in constant time for a given input length.
Documentation
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
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
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