| Copyright | (C) Seth Livy 2022 |
|---|---|
| License | BSD-3-Clause |
| Maintainer | The Haskell Cryptography Group |
| Stability | Stable |
| Portability | GHC only |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
LibSodium.Bindings.Utils
Contents
Description
These are bindings to some of libsodium's utils.h.
Included are Hex and Base64 encoding/decoding functions along with a constant-time memcmp for handling secret data.
Synopsis
- sodiumMemcmp :: Ptr CUChar -> Ptr CUChar -> CSize -> IO CInt
- sodiumBin2Hex :: CString -> CSize -> Ptr CUChar -> CSize -> IO CString
- sodiumBin2Base64 :: CString -> CSize -> Ptr CUChar -> CSize -> CInt -> IO CString
- sodiumBase64VariantOriginal :: CInt
- sodiumBase64VariantOriginalNoPadding :: CInt
- sodiumBase64VariantURLSafe :: CInt
- sodiumBase64VariantURLSafeNoPadding :: CInt
Low-level binding
Arguments
| :: Ptr CUChar | First pointer to some secret data. |
| -> Ptr CUChar | Second pointer to some secret data. Must be the same length as the first pointer. |
| -> CSize | The length of bytes that pointed to by both previous arguments. |
| -> IO CInt | 0 if successful, -1 on failure. |
Constant-time comparison function.
This function is not a lexicographic comparator and should be never used for this purpose. It should only be used when comparing two pieces of secret data, such as keys or authentication tags.
Since: 0.0.1.0
Arguments
| :: CString |
|
| -> CSize |
|
| -> Ptr CUChar |
|
| -> CSize |
|
| -> IO CString | The return string, terminated with a null byte. |
Encode bytes to a hexidecimal string. Constant-time.
Since: 0.0.1.0
Arguments
| :: CString |
|
| -> CSize |
|
| -> Ptr CUChar |
|
| -> CSize |
|
| -> CInt |
|
| -> IO CString | The returned Base64 string, terminated with a null byte. |
Encode bytes to a Base64 string. Constant-time.
Constants
sodiumBase64VariantOriginal :: CInt Source #
The original variant of Base64 with padding. This ensures that the length of the encoded data will always be a multiple of four bytes.
sodiumBase64VariantOriginalNoPadding :: CInt Source #
The original variant of Base64. No variant offers any security advantages over the other.
sodiumBase64VariantURLSafe :: CInt Source #
The URL-safe variant of Base64 with padding.