libsodium-bindings-0.0.1.0: FFI bindings to libsodium
Copyright(C) Koz Ross 2022
LicenseBSD-3-Clause
Maintainerkoz.ross@retro-freedom.nz
StabilityStable
PortabilityGHC only
Safe HaskellSafe-Inferred
LanguageHaskell2010

LibSodium.Bindings.Main

Description

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

High-level wrappers

secureMain Source #

Arguments

:: forall (a :: Type). IO a

Action that will perform cryptographic operations

-> IO a 

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

secureMainWithError Source #

Arguments

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

sodiumInit Source #

Arguments

:: IO CInt

0 if successful, -1 on failure, 1 on repeat calls

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