Copyright | (C) Koz Ross 2022 |
---|---|
License | BSD-3-Clause |
Maintainer | koz.ross@retro-freedom.nz |
Stability | Stable |
Portability | GHC only |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
libsodium
requires initialisation before use. We provide a binding to the
initialisation function, as well as some high-level wrappers for applications
to use without needing to call an FFI wrapper.
Note
If you are using cryptography-libsodium
as a dependency for a library, you
are probably not interested in this; it's designed for application authors who
need capabilities provided by cryptography-libsodium
.
Synopsis
- secureMain :: forall (a :: Type). IO a -> IO a
- secureMainWithError :: forall (a :: Type). IO a -> IO a -> IO a
- sodiumInit :: IO CInt
High-level wrappers
Initialise all security-related functionality, then perform the given
action. Abort with an error message if security-related functionality cannot
be initialised. This will also indicate failure to the shell, as with die
.
Use
main :: IO () main = secureMain doTheThingIActuallyWant
Since: 0.0.1.0
:: forall (a :: Type). IO a | Code to execute if there is an initialisation failure. |
-> IO a | Action that will perform cryptographic operations after libsodium is initialised. |
-> IO a |
Similar to secureMain
, but allows responding to a failure of
initialisation.
Use
main :: IO () main = secureMainWith reportErrorWithLogging doTheThingIActuallyWant
Since: 0.0.1.0
Low-level binding
Initialise libsodium
for future use. This only needs to be called once,
before any use of any other functionality, but multiple calls to this
function are not harmful (just redundant).
See: sodium_init()
Since: 0.0.1.0