argon2-1.3.0.1: Memory-hard password hash and proof-of-work function

License | BSD3
Maintainer | hvr@gnu.org
Safe Haskell | Unsafe
Language | Haskell2010

Crypto.Argon2.FFI

Contents

- `libargon2` functions
- `libargon2` API typedefs
  - `argon2_type`
  - `argon2_version`
  - `argon2_error_codes`
- `libargon2` limits & constants

Description

This module provides low-level access to parts of the C API

Prefer the Crypto.Argon2 API when possible.

Synopsis

- argon2_hash :: Word32 -> Word32 -> Word32 -> Ptr a -> CSize -> Ptr b -> CSize -> Ptr c -> CSize -> CString -> CSize -> Argon2_type -> Argon2_version -> IO CInt
- argon2_verify :: CString -> Ptr a -> CSize -> Argon2_type -> IO CInt
- argon2_encodedlen :: Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Argon2_type -> CSize
- type Argon2_type = Word32
- pattern Argon2_d :: forall a. (Eq a, Num a) => a
- pattern Argon2_i :: forall a. (Eq a, Num a) => a
- pattern Argon2_id :: forall a. (Eq a, Num a) => a
- type Argon2_version = Word32
- pattern ARGON2_VERSION_10 :: forall a. (Eq a, Num a) => a
- pattern ARGON2_VERSION_13 :: forall a. (Eq a, Num a) => a
- pattern ARGON2_VERSION_NUMBER :: forall a. (Eq a, Num a) => a
- pattern ARGON2_OK :: forall a. (Eq a, Num a) => a
- pattern ARGON2_OUTPUT_PTR_NULL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_OUTPUT_TOO_SHORT :: forall a. (Eq a, Num a) => a
- pattern ARGON2_OUTPUT_TOO_LONG :: forall a. (Eq a, Num a) => a
- pattern ARGON2_PWD_TOO_SHORT :: forall a. (Eq a, Num a) => a
- pattern ARGON2_PWD_TOO_LONG :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SALT_TOO_SHORT :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SALT_TOO_LONG :: forall a. (Eq a, Num a) => a
- pattern ARGON2_AD_TOO_SHORT :: forall a. (Eq a, Num a) => a
- pattern ARGON2_AD_TOO_LONG :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SECRET_TOO_SHORT :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SECRET_TOO_LONG :: forall a. (Eq a, Num a) => a
- pattern ARGON2_TIME_TOO_SMALL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_TIME_TOO_LARGE :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MEMORY_TOO_LITTLE :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MEMORY_TOO_MUCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_LANES_TOO_FEW :: forall a. (Eq a, Num a) => a
- pattern ARGON2_LANES_TOO_MANY :: forall a. (Eq a, Num a) => a
- pattern ARGON2_PWD_PTR_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SALT_PTR_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SECRET_PTR_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_AD_PTR_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MEMORY_ALLOCATION_ERROR :: forall a. (Eq a, Num a) => a
- pattern ARGON2_FREE_MEMORY_CBK_NULL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_ALLOCATE_MEMORY_CBK_NULL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_INCORRECT_PARAMETER :: forall a. (Eq a, Num a) => a
- pattern ARGON2_INCORRECT_TYPE :: forall a. (Eq a, Num a) => a
- pattern ARGON2_OUT_PTR_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_THREADS_TOO_FEW :: forall a. (Eq a, Num a) => a
- pattern ARGON2_THREADS_TOO_MANY :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MISSING_ARGS :: forall a. (Eq a, Num a) => a
- pattern ARGON2_ENCODING_FAIL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_DECODING_FAIL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_THREAD_FAIL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_DECODING_LENGTH_FAIL :: forall a. (Eq a, Num a) => a
- pattern ARGON2_VERIFY_MISMATCH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_LANES :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_LANES :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_THREADS :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_THREADS :: forall a. (Eq a, Num a) => a
- pattern ARGON2_SYNC_POINTS :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_OUTLEN :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_OUTLEN :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_MEMORY :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_MEMORY_BITS :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_MEMORY :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_TIME :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_TIME :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_PWD_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_PWD_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_AD_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_AD_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_SALT_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_SALT_LENGTH :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MIN_SECRET :: forall a. (Eq a, Num a) => a
- pattern ARGON2_MAX_SECRET :: forall a. (Eq a, Num a) => a

# `libargon2` functions

argon2_hash :: Word32 -> Word32 -> Word32 -> Ptr a -> CSize -> Ptr b -> CSize -> Ptr c -> CSize -> CString -> CSize -> Argon2_type -> Argon2_version -> IO CInt Source #

Compute Argon2 hash

    int argon2_hash(const uint32_t t_cost, const uint32_t m_cost,
                    const uint32_t parallelism, const void *pwd,
                    const size_t pwdlen, const void *salt,
                    const size_t saltlen, void *hash,
                    const size_t hashlen, char *encoded,
                    const size_t encodedlen, argon2_type type,
                    const uint32_t version);

### Parameters

Expand

t_cost
  Number of iterations
m_cost
  Sets memory usage to m_cost kibibytes
parallelism
  Number of threads and compute lanes
pwd
  Pointer to password
pwdlen
  Password size in bytes
salt
  Pointer to salt
saltlen
  Salt size in bytes
hash
  Buffer where to write the raw hash
hashlen
  Desired length of the hash in bytes
encoded
  Buffer where to write the encoded hash
encodedlen
  Size of the buffer (thus max size of the encoded hash)
type
  Variant of Argon2 hash
version
  Version of Argon2 specification

argon2_verify :: CString -> Ptr a -> CSize -> Argon2_type -> IO CInt Source #

Verify encoded hash

    int argon2_verify(const char *encoded, const void *pwd,
                      const size_t pwdlen, argon2_type type);

### Parameters

Expand

encoded
  Pointer to zero-terminated encoded hash
pwd
  Pointer to password
pwdlen
  Password size in bytes
type
  Variant of Argon2 hash

argon2_encodedlen :: Word32 -> Word32 -> Word32 -> Word32 -> Word32 -> Argon2_type -> CSize Source #

Compute size of encoded hash

    size_t argon2_encodedlen(uint32_t t_cost, uint32_t m_cost, uint32_t parallelism,
                             uint32_t saltlen, uint32_t hashlen, argon2_type type);

### Parameters

Expand

t_cost
  Number of iterations
m_cost
  Sets memory usage to m_cost kibibytes
parallelism
  Number of threads and compute lanes
salt
  Pointer to salt
saltlen
  Salt size in bytes
hashlen
  Desired length of the hash in bytes
type
  Variant of Argon2 hash

# `libargon2` API typedefs

## `argon2_type`

type Argon2_type = Word32 Source #

pattern Argon2_d :: forall a. (Eq a, Num a) => a Source #

pattern Argon2_i :: forall a. (Eq a, Num a) => a Source #

pattern Argon2_id :: forall a. (Eq a, Num a) => a Source #

## `argon2_version`

type Argon2_version = Word32 Source #

pattern ARGON2_VERSION_10 :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_VERSION_13 :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_VERSION_NUMBER :: forall a. (Eq a, Num a) => a Source #

## `argon2_error_codes`

pattern ARGON2_OK :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_OUTPUT_PTR_NULL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_OUTPUT_TOO_SHORT :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_OUTPUT_TOO_LONG :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_PWD_TOO_SHORT :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_PWD_TOO_LONG :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SALT_TOO_SHORT :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SALT_TOO_LONG :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_AD_TOO_SHORT :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_AD_TOO_LONG :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SECRET_TOO_SHORT :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SECRET_TOO_LONG :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_TIME_TOO_SMALL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_TIME_TOO_LARGE :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MEMORY_TOO_LITTLE :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MEMORY_TOO_MUCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_LANES_TOO_FEW :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_LANES_TOO_MANY :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_PWD_PTR_MISMATCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SALT_PTR_MISMATCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SECRET_PTR_MISMATCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_AD_PTR_MISMATCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MEMORY_ALLOCATION_ERROR :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_FREE_MEMORY_CBK_NULL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_ALLOCATE_MEMORY_CBK_NULL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_INCORRECT_PARAMETER :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_INCORRECT_TYPE :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_OUT_PTR_MISMATCH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_THREADS_TOO_FEW :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_THREADS_TOO_MANY :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MISSING_ARGS :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_ENCODING_FAIL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_DECODING_FAIL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_THREAD_FAIL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_DECODING_LENGTH_FAIL :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_VERIFY_MISMATCH :: forall a. (Eq a, Num a) => a Source #

# `libargon2` limits & constants

pattern ARGON2_MIN_LANES :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_LANES :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_THREADS :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_THREADS :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_SYNC_POINTS :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_OUTLEN :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_OUTLEN :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_MEMORY :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_MEMORY_BITS :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_MEMORY :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_TIME :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_TIME :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_PWD_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_PWD_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_AD_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_AD_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_SALT_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_SALT_LENGTH :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MIN_SECRET :: forall a. (Eq a, Num a) => a Source #

pattern ARGON2_MAX_SECRET :: forall a. (Eq a, Num a) => a Source #