{-# LANGUAGE DeriveDataTypeable, GeneralizedNewtypeDeriving, DeriveGeneric, ForeignFunctionInterface #-}

-- |
-- Module      : Crypto.Saltine.Internal.Password
-- Copyright   : (c) Promethea Raschke 2018
--                   Max Amanshauser 2021
-- License     : MIT
-- Maintainer  : max@lambdalifting.org
-- Stability   : experimental
-- Portability : non-portable

module Crypto.Saltine.Internal.Password
  ( c_pwhash
  , c_pwhash_str
  , c_pwhash_str_verify
  , c_pwhash_str_needs_rehash

  , pwhash_alg_argon2i13
  , pwhash_alg_argon2id13
  , pwhash_alg_default
  , algorithm

  -- Default algorithm constants
  , pwhash_bytes_max
  , pwhash_bytes_min

  , pwhash_memlimit_interactive
  , pwhash_memlimit_moderate
  , pwhash_memlimit_sensitive
  , pwhash_memlimit_min
  , pwhash_memlimit_max

  , pwhash_opslimit_interactive
  , pwhash_opslimit_moderate
  , pwhash_opslimit_sensitive
  , pwhash_opslimit_min
  , pwhash_opslimit_max

  , pwhash_passwd_min
  , pwhash_passwd_max
  , pwhash_saltbytes
  , pwhash_strbytes
  , pwhash_strprefix

  -- Argon2i algorithm constants
  , pwhash_argon2i_bytes_max
  , pwhash_argon2i_bytes_min

  , pwhash_argon2i_memlimit_interactive
  , pwhash_argon2i_memlimit_moderate
  , pwhash_argon2i_memlimit_sensitive
  , pwhash_argon2i_memlimit_min
  , pwhash_argon2i_memlimit_max

  , pwhash_argon2i_opslimit_interactive
  , pwhash_argon2i_opslimit_moderate
  , pwhash_argon2i_opslimit_sensitive
  , pwhash_argon2i_opslimit_min
  , pwhash_argon2i_opslimit_max

  , pwhash_argon2i_passwd_min
  , pwhash_argon2i_passwd_max
  , pwhash_argon2i_saltbytes
  , pwhash_argon2i_strbytes
  , pwhash_argon2i_strprefix

  -- Argon2id algorithm constants
  , pwhash_argon2id_bytes_max
  , pwhash_argon2id_bytes_min

  , pwhash_argon2id_memlimit_interactive
  , pwhash_argon2id_memlimit_moderate
  , pwhash_argon2id_memlimit_sensitive
  , pwhash_argon2id_memlimit_min
  , pwhash_argon2id_memlimit_max

  , pwhash_argon2id_opslimit_interactive
  , pwhash_argon2id_opslimit_moderate
  , pwhash_argon2id_opslimit_sensitive
  , pwhash_argon2id_opslimit_min
  , pwhash_argon2id_opslimit_max

  , pwhash_argon2id_passwd_min
  , pwhash_argon2id_passwd_max
  , pwhash_argon2id_saltbytes
  , pwhash_argon2id_strbytes
  , pwhash_argon2id_strprefix

  , Salt(..)
  , PasswordHash(..)
  , Opslimit(..)
  , Memlimit(..)
  , Policy(..)
  , Algorithm(..)
  ) where

import Control.DeepSeq
import Crypto.Saltine.Class
import Crypto.Saltine.Internal.Util as U
import Data.ByteString              (ByteString)
import Data.Data                    (Data, Typeable)
import Data.Hashable                (Hashable)
import Data.Monoid
import Data.Text                    (Text)
import GHC.Generics                 (Generic)
import Foreign.C
import Foreign.Ptr

import qualified Data.ByteString    as S
import qualified Data.Text.Encoding as DTE


-- | Salt for deriving keys from passwords
newtype Salt = Salt { Salt -> ByteString
unSalt :: ByteString } deriving (Eq Salt
Eq Salt
-> (Salt -> Salt -> Ordering)
-> (Salt -> Salt -> Bool)
-> (Salt -> Salt -> Bool)
-> (Salt -> Salt -> Bool)
-> (Salt -> Salt -> Bool)
-> (Salt -> Salt -> Salt)
-> (Salt -> Salt -> Salt)
-> Ord Salt
Salt -> Salt -> Bool
Salt -> Salt -> Ordering
Salt -> Salt -> Salt
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Salt -> Salt -> Ordering
compare :: Salt -> Salt -> Ordering
$c< :: Salt -> Salt -> Bool
< :: Salt -> Salt -> Bool
$c<= :: Salt -> Salt -> Bool
<= :: Salt -> Salt -> Bool
$c> :: Salt -> Salt -> Bool
> :: Salt -> Salt -> Bool
$c>= :: Salt -> Salt -> Bool
>= :: Salt -> Salt -> Bool
$cmax :: Salt -> Salt -> Salt
max :: Salt -> Salt -> Salt
$cmin :: Salt -> Salt -> Salt
min :: Salt -> Salt -> Salt
Ord, Typeable Salt
Typeable Salt
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Salt -> c Salt)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Salt)
-> (Salt -> Constr)
-> (Salt -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Salt))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt))
-> ((forall b. Data b => b -> b) -> Salt -> Salt)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r)
-> (forall u. (forall d. Data d => d -> u) -> Salt -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Salt -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Salt -> m Salt)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Salt -> m Salt)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Salt -> m Salt)
-> Data Salt
Salt -> Constr
Salt -> DataType
(forall b. Data b => b -> b) -> Salt -> Salt
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Salt -> u
forall u. (forall d. Data d => d -> u) -> Salt -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Salt
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Salt)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Salt
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Salt
$ctoConstr :: Salt -> Constr
toConstr :: Salt -> Constr
$cdataTypeOf :: Salt -> DataType
dataTypeOf :: Salt -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Salt)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Salt)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt)
$cgmapT :: (forall b. Data b => b -> b) -> Salt -> Salt
gmapT :: (forall b. Data b => b -> b) -> Salt -> Salt
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Salt -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Salt -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Salt -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Salt -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
Data, Eq Salt
Eq Salt -> (Int -> Salt -> Int) -> (Salt -> Int) -> Hashable Salt
Int -> Salt -> Int
Salt -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Salt -> Int
hashWithSalt :: Int -> Salt -> Int
$chash :: Salt -> Int
hash :: Salt -> Int
Hashable, Typeable, (forall x. Salt -> Rep Salt x)
-> (forall x. Rep Salt x -> Salt) -> Generic Salt
forall x. Rep Salt x -> Salt
forall x. Salt -> Rep Salt x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Salt -> Rep Salt x
from :: forall x. Salt -> Rep Salt x
$cto :: forall x. Rep Salt x -> Salt
to :: forall x. Rep Salt x -> Salt
Generic, Salt -> ()
(Salt -> ()) -> NFData Salt
forall a. (a -> ()) -> NFData a
$crnf :: Salt -> ()
rnf :: Salt -> ()
NFData)
instance Eq Salt where
    Salt ByteString
a == :: Salt -> Salt -> Bool
== Salt ByteString
b = ByteString -> ByteString -> Bool
U.compare ByteString
a ByteString
b
instance Show Salt where
    show :: Salt -> String
show Salt
k = String
"Password.Salt " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ByteString -> String
bin2hex (Salt -> ByteString
forall a. IsEncoding a => a -> ByteString
encode Salt
k)

instance IsEncoding Salt where
  decode :: ByteString -> Maybe Salt
decode ByteString
v = if ByteString -> Int
S.length ByteString
v Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
pwhash_saltbytes
           then Salt -> Maybe Salt
forall a. a -> Maybe a
Just (ByteString -> Salt
Salt ByteString
v)
           else Maybe Salt
forall a. Maybe a
Nothing
  {-# INLINE decode #-}
  encode :: Salt -> ByteString
encode (Salt ByteString
v) = ByteString
v
  {-# INLINE encode #-}

-- | Verification string for stored passwords
-- This hash contains only printable characters, hence we can just derive Show.
newtype PasswordHash = PasswordHash { PasswordHash -> Text
unPasswordHash :: Text } deriving (Eq PasswordHash
Eq PasswordHash
-> (PasswordHash -> PasswordHash -> Ordering)
-> (PasswordHash -> PasswordHash -> Bool)
-> (PasswordHash -> PasswordHash -> Bool)
-> (PasswordHash -> PasswordHash -> Bool)
-> (PasswordHash -> PasswordHash -> Bool)
-> (PasswordHash -> PasswordHash -> PasswordHash)
-> (PasswordHash -> PasswordHash -> PasswordHash)
-> Ord PasswordHash
PasswordHash -> PasswordHash -> Bool
PasswordHash -> PasswordHash -> Ordering
PasswordHash -> PasswordHash -> PasswordHash
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PasswordHash -> PasswordHash -> Ordering
compare :: PasswordHash -> PasswordHash -> Ordering
$c< :: PasswordHash -> PasswordHash -> Bool
< :: PasswordHash -> PasswordHash -> Bool
$c<= :: PasswordHash -> PasswordHash -> Bool
<= :: PasswordHash -> PasswordHash -> Bool
$c> :: PasswordHash -> PasswordHash -> Bool
> :: PasswordHash -> PasswordHash -> Bool
$c>= :: PasswordHash -> PasswordHash -> Bool
>= :: PasswordHash -> PasswordHash -> Bool
$cmax :: PasswordHash -> PasswordHash -> PasswordHash
max :: PasswordHash -> PasswordHash -> PasswordHash
$cmin :: PasswordHash -> PasswordHash -> PasswordHash
min :: PasswordHash -> PasswordHash -> PasswordHash
Ord, Typeable PasswordHash
Typeable PasswordHash
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> PasswordHash -> c PasswordHash)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c PasswordHash)
-> (PasswordHash -> Constr)
-> (PasswordHash -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c PasswordHash))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c PasswordHash))
-> ((forall b. Data b => b -> b) -> PasswordHash -> PasswordHash)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> PasswordHash -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> PasswordHash -> r)
-> (forall u. (forall d. Data d => d -> u) -> PasswordHash -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> PasswordHash -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash)
-> Data PasswordHash
PasswordHash -> Constr
PasswordHash -> DataType
(forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> PasswordHash -> u
forall u. (forall d. Data d => d -> u) -> PasswordHash -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PasswordHash
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PasswordHash)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PasswordHash)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PasswordHash
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PasswordHash
$ctoConstr :: PasswordHash -> Constr
toConstr :: PasswordHash -> Constr
$cdataTypeOf :: PasswordHash -> DataType
dataTypeOf :: PasswordHash -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PasswordHash)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PasswordHash)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PasswordHash)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PasswordHash)
$cgmapT :: (forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
gmapT :: (forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PasswordHash -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> PasswordHash -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PasswordHash -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PasswordHash -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
Data, Eq PasswordHash
Eq PasswordHash
-> (Int -> PasswordHash -> Int)
-> (PasswordHash -> Int)
-> Hashable PasswordHash
Int -> PasswordHash -> Int
PasswordHash -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> PasswordHash -> Int
hashWithSalt :: Int -> PasswordHash -> Int
$chash :: PasswordHash -> Int
hash :: PasswordHash -> Int
Hashable, Typeable, (forall x. PasswordHash -> Rep PasswordHash x)
-> (forall x. Rep PasswordHash x -> PasswordHash)
-> Generic PasswordHash
forall x. Rep PasswordHash x -> PasswordHash
forall x. PasswordHash -> Rep PasswordHash x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PasswordHash -> Rep PasswordHash x
from :: forall x. PasswordHash -> Rep PasswordHash x
$cto :: forall x. Rep PasswordHash x -> PasswordHash
to :: forall x. Rep PasswordHash x -> PasswordHash
Generic, Int -> PasswordHash -> ShowS
[PasswordHash] -> ShowS
PasswordHash -> String
(Int -> PasswordHash -> ShowS)
-> (PasswordHash -> String)
-> ([PasswordHash] -> ShowS)
-> Show PasswordHash
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PasswordHash -> ShowS
showsPrec :: Int -> PasswordHash -> ShowS
$cshow :: PasswordHash -> String
show :: PasswordHash -> String
$cshowList :: [PasswordHash] -> ShowS
showList :: [PasswordHash] -> ShowS
Show, PasswordHash -> ()
(PasswordHash -> ()) -> NFData PasswordHash
forall a. (a -> ()) -> NFData a
$crnf :: PasswordHash -> ()
rnf :: PasswordHash -> ()
NFData)
-- Constant time Eq instance, just in case.
instance Eq PasswordHash where
    PasswordHash Text
a == :: PasswordHash -> PasswordHash -> Bool
== PasswordHash Text
b = ByteString -> ByteString -> Bool
U.compare (Text -> ByteString
DTE.encodeUtf8 Text
a) (Text -> ByteString
DTE.encodeUtf8 Text
b)

-- | Wrapper type for the operations used by password hashing
newtype Opslimit = Opslimit { Opslimit -> Int
getOpslimit :: Int } deriving (Opslimit -> Opslimit -> Bool
(Opslimit -> Opslimit -> Bool)
-> (Opslimit -> Opslimit -> Bool) -> Eq Opslimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Opslimit -> Opslimit -> Bool
== :: Opslimit -> Opslimit -> Bool
$c/= :: Opslimit -> Opslimit -> Bool
/= :: Opslimit -> Opslimit -> Bool
Eq, Eq Opslimit
Eq Opslimit
-> (Opslimit -> Opslimit -> Ordering)
-> (Opslimit -> Opslimit -> Bool)
-> (Opslimit -> Opslimit -> Bool)
-> (Opslimit -> Opslimit -> Bool)
-> (Opslimit -> Opslimit -> Bool)
-> (Opslimit -> Opslimit -> Opslimit)
-> (Opslimit -> Opslimit -> Opslimit)
-> Ord Opslimit
Opslimit -> Opslimit -> Bool
Opslimit -> Opslimit -> Ordering
Opslimit -> Opslimit -> Opslimit
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Opslimit -> Opslimit -> Ordering
compare :: Opslimit -> Opslimit -> Ordering
$c< :: Opslimit -> Opslimit -> Bool
< :: Opslimit -> Opslimit -> Bool
$c<= :: Opslimit -> Opslimit -> Bool
<= :: Opslimit -> Opslimit -> Bool
$c> :: Opslimit -> Opslimit -> Bool
> :: Opslimit -> Opslimit -> Bool
$c>= :: Opslimit -> Opslimit -> Bool
>= :: Opslimit -> Opslimit -> Bool
$cmax :: Opslimit -> Opslimit -> Opslimit
max :: Opslimit -> Opslimit -> Opslimit
$cmin :: Opslimit -> Opslimit -> Opslimit
min :: Opslimit -> Opslimit -> Opslimit
Ord, Typeable Opslimit
Typeable Opslimit
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Opslimit -> c Opslimit)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Opslimit)
-> (Opslimit -> Constr)
-> (Opslimit -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Opslimit))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit))
-> ((forall b. Data b => b -> b) -> Opslimit -> Opslimit)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Opslimit -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Opslimit -> r)
-> (forall u. (forall d. Data d => d -> u) -> Opslimit -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Opslimit -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Opslimit -> m Opslimit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Opslimit -> m Opslimit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Opslimit -> m Opslimit)
-> Data Opslimit
Opslimit -> Constr
Opslimit -> DataType
(forall b. Data b => b -> b) -> Opslimit -> Opslimit
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Opslimit -> u
forall u. (forall d. Data d => d -> u) -> Opslimit -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Opslimit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Opslimit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Opslimit
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Opslimit
$ctoConstr :: Opslimit -> Constr
toConstr :: Opslimit -> Constr
$cdataTypeOf :: Opslimit -> DataType
dataTypeOf :: Opslimit -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Opslimit)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Opslimit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit)
$cgmapT :: (forall b. Data b => b -> b) -> Opslimit -> Opslimit
gmapT :: (forall b. Data b => b -> b) -> Opslimit -> Opslimit
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Opslimit -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Opslimit -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Opslimit -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Opslimit -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
Data, Eq Opslimit
Eq Opslimit
-> (Int -> Opslimit -> Int)
-> (Opslimit -> Int)
-> Hashable Opslimit
Int -> Opslimit -> Int
Opslimit -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Opslimit -> Int
hashWithSalt :: Int -> Opslimit -> Int
$chash :: Opslimit -> Int
hash :: Opslimit -> Int
Hashable, Typeable, (forall x. Opslimit -> Rep Opslimit x)
-> (forall x. Rep Opslimit x -> Opslimit) -> Generic Opslimit
forall x. Rep Opslimit x -> Opslimit
forall x. Opslimit -> Rep Opslimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Opslimit -> Rep Opslimit x
from :: forall x. Opslimit -> Rep Opslimit x
$cto :: forall x. Rep Opslimit x -> Opslimit
to :: forall x. Rep Opslimit x -> Opslimit
Generic, Int -> Opslimit -> ShowS
[Opslimit] -> ShowS
Opslimit -> String
(Int -> Opslimit -> ShowS)
-> (Opslimit -> String) -> ([Opslimit] -> ShowS) -> Show Opslimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Opslimit -> ShowS
showsPrec :: Int -> Opslimit -> ShowS
$cshow :: Opslimit -> String
show :: Opslimit -> String
$cshowList :: [Opslimit] -> ShowS
showList :: [Opslimit] -> ShowS
Show, Opslimit -> ()
(Opslimit -> ()) -> NFData Opslimit
forall a. (a -> ()) -> NFData a
$crnf :: Opslimit -> ()
rnf :: Opslimit -> ()
NFData)

-- | Wrapper type for the memory used by password hashing
newtype Memlimit = Memlimit { Memlimit -> Int
getMemlimit :: Int } deriving (Memlimit -> Memlimit -> Bool
(Memlimit -> Memlimit -> Bool)
-> (Memlimit -> Memlimit -> Bool) -> Eq Memlimit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Memlimit -> Memlimit -> Bool
== :: Memlimit -> Memlimit -> Bool
$c/= :: Memlimit -> Memlimit -> Bool
/= :: Memlimit -> Memlimit -> Bool
Eq, Eq Memlimit
Eq Memlimit
-> (Memlimit -> Memlimit -> Ordering)
-> (Memlimit -> Memlimit -> Bool)
-> (Memlimit -> Memlimit -> Bool)
-> (Memlimit -> Memlimit -> Bool)
-> (Memlimit -> Memlimit -> Bool)
-> (Memlimit -> Memlimit -> Memlimit)
-> (Memlimit -> Memlimit -> Memlimit)
-> Ord Memlimit
Memlimit -> Memlimit -> Bool
Memlimit -> Memlimit -> Ordering
Memlimit -> Memlimit -> Memlimit
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Memlimit -> Memlimit -> Ordering
compare :: Memlimit -> Memlimit -> Ordering
$c< :: Memlimit -> Memlimit -> Bool
< :: Memlimit -> Memlimit -> Bool
$c<= :: Memlimit -> Memlimit -> Bool
<= :: Memlimit -> Memlimit -> Bool
$c> :: Memlimit -> Memlimit -> Bool
> :: Memlimit -> Memlimit -> Bool
$c>= :: Memlimit -> Memlimit -> Bool
>= :: Memlimit -> Memlimit -> Bool
$cmax :: Memlimit -> Memlimit -> Memlimit
max :: Memlimit -> Memlimit -> Memlimit
$cmin :: Memlimit -> Memlimit -> Memlimit
min :: Memlimit -> Memlimit -> Memlimit
Ord, Typeable Memlimit
Typeable Memlimit
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Memlimit -> c Memlimit)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Memlimit)
-> (Memlimit -> Constr)
-> (Memlimit -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Memlimit))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit))
-> ((forall b. Data b => b -> b) -> Memlimit -> Memlimit)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Memlimit -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Memlimit -> r)
-> (forall u. (forall d. Data d => d -> u) -> Memlimit -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Memlimit -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Memlimit -> m Memlimit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Memlimit -> m Memlimit)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Memlimit -> m Memlimit)
-> Data Memlimit
Memlimit -> Constr
Memlimit -> DataType
(forall b. Data b => b -> b) -> Memlimit -> Memlimit
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Memlimit -> u
forall u. (forall d. Data d => d -> u) -> Memlimit -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Memlimit
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Memlimit)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Memlimit
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Memlimit
$ctoConstr :: Memlimit -> Constr
toConstr :: Memlimit -> Constr
$cdataTypeOf :: Memlimit -> DataType
dataTypeOf :: Memlimit -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Memlimit)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Memlimit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit)
$cgmapT :: (forall b. Data b => b -> b) -> Memlimit -> Memlimit
gmapT :: (forall b. Data b => b -> b) -> Memlimit -> Memlimit
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Memlimit -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Memlimit -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Memlimit -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Memlimit -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
Data, Eq Memlimit
Eq Memlimit
-> (Int -> Memlimit -> Int)
-> (Memlimit -> Int)
-> Hashable Memlimit
Int -> Memlimit -> Int
Memlimit -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
$chashWithSalt :: Int -> Memlimit -> Int
hashWithSalt :: Int -> Memlimit -> Int
$chash :: Memlimit -> Int
hash :: Memlimit -> Int
Hashable, Typeable, (forall x. Memlimit -> Rep Memlimit x)
-> (forall x. Rep Memlimit x -> Memlimit) -> Generic Memlimit
forall x. Rep Memlimit x -> Memlimit
forall x. Memlimit -> Rep Memlimit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Memlimit -> Rep Memlimit x
from :: forall x. Memlimit -> Rep Memlimit x
$cto :: forall x. Rep Memlimit x -> Memlimit
to :: forall x. Rep Memlimit x -> Memlimit
Generic, Int -> Memlimit -> ShowS
[Memlimit] -> ShowS
Memlimit -> String
(Int -> Memlimit -> ShowS)
-> (Memlimit -> String) -> ([Memlimit] -> ShowS) -> Show Memlimit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Memlimit -> ShowS
showsPrec :: Int -> Memlimit -> ShowS
$cshow :: Memlimit -> String
show :: Memlimit -> String
$cshowList :: [Memlimit] -> ShowS
showList :: [Memlimit] -> ShowS
Show, Memlimit -> ()
(Memlimit -> ()) -> NFData Memlimit
forall a. (a -> ()) -> NFData a
$crnf :: Memlimit -> ()
rnf :: Memlimit -> ()
NFData)

-- | Wrapper for opslimit, memlimit and algorithm
data Policy = Policy
  { Policy -> Opslimit
opsPolicy :: Opslimit
  , Policy -> Memlimit
memPolicy :: Memlimit
  , Policy -> Algorithm
algPolicy :: Algorithm
  } deriving (Policy -> Policy -> Bool
(Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool) -> Eq Policy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Policy -> Policy -> Bool
== :: Policy -> Policy -> Bool
$c/= :: Policy -> Policy -> Bool
/= :: Policy -> Policy -> Bool
Eq, Eq Policy
Eq Policy
-> (Policy -> Policy -> Ordering)
-> (Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool)
-> (Policy -> Policy -> Bool)
-> (Policy -> Policy -> Policy)
-> (Policy -> Policy -> Policy)
-> Ord Policy
Policy -> Policy -> Bool
Policy -> Policy -> Ordering
Policy -> Policy -> Policy
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Policy -> Policy -> Ordering
compare :: Policy -> Policy -> Ordering
$c< :: Policy -> Policy -> Bool
< :: Policy -> Policy -> Bool
$c<= :: Policy -> Policy -> Bool
<= :: Policy -> Policy -> Bool
$c> :: Policy -> Policy -> Bool
> :: Policy -> Policy -> Bool
$c>= :: Policy -> Policy -> Bool
>= :: Policy -> Policy -> Bool
$cmax :: Policy -> Policy -> Policy
max :: Policy -> Policy -> Policy
$cmin :: Policy -> Policy -> Policy
min :: Policy -> Policy -> Policy
Ord, Typeable Policy
Typeable Policy
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Policy -> c Policy)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Policy)
-> (Policy -> Constr)
-> (Policy -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Policy))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy))
-> ((forall b. Data b => b -> b) -> Policy -> Policy)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Policy -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Policy -> r)
-> (forall u. (forall d. Data d => d -> u) -> Policy -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Policy -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Policy -> m Policy)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Policy -> m Policy)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Policy -> m Policy)
-> Data Policy
Policy -> Constr
Policy -> DataType
(forall b. Data b => b -> b) -> Policy -> Policy
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Policy -> u
forall u. (forall d. Data d => d -> u) -> Policy -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Policy
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Policy)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Policy
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Policy
$ctoConstr :: Policy -> Constr
toConstr :: Policy -> Constr
$cdataTypeOf :: Policy -> DataType
dataTypeOf :: Policy -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Policy)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Policy)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy)
$cgmapT :: (forall b. Data b => b -> b) -> Policy -> Policy
gmapT :: (forall b. Data b => b -> b) -> Policy -> Policy
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Policy -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Policy -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Policy -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Policy -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
Data, Typeable, (forall x. Policy -> Rep Policy x)
-> (forall x. Rep Policy x -> Policy) -> Generic Policy
forall x. Rep Policy x -> Policy
forall x. Policy -> Rep Policy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Policy -> Rep Policy x
from :: forall x. Policy -> Rep Policy x
$cto :: forall x. Rep Policy x -> Policy
to :: forall x. Rep Policy x -> Policy
Generic, Int -> Policy -> ShowS
[Policy] -> ShowS
Policy -> String
(Int -> Policy -> ShowS)
-> (Policy -> String) -> ([Policy] -> ShowS) -> Show Policy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Policy -> ShowS
showsPrec :: Int -> Policy -> ShowS
$cshow :: Policy -> String
show :: Policy -> String
$cshowList :: [Policy] -> ShowS
showList :: [Policy] -> ShowS
Show)
instance Hashable Policy

-- | Algorithms known to Libsodium, as an enum datatype
data Algorithm
  = DefaultAlgorithm
  | Argon2i13
  | Argon2id13
  deriving (Algorithm -> Algorithm -> Bool
(Algorithm -> Algorithm -> Bool)
-> (Algorithm -> Algorithm -> Bool) -> Eq Algorithm
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Algorithm -> Algorithm -> Bool
== :: Algorithm -> Algorithm -> Bool
$c/= :: Algorithm -> Algorithm -> Bool
/= :: Algorithm -> Algorithm -> Bool
Eq, Int -> Algorithm
Algorithm -> Int
Algorithm -> [Algorithm]
Algorithm -> Algorithm
Algorithm -> Algorithm -> [Algorithm]
Algorithm -> Algorithm -> Algorithm -> [Algorithm]
(Algorithm -> Algorithm)
-> (Algorithm -> Algorithm)
-> (Int -> Algorithm)
-> (Algorithm -> Int)
-> (Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> [Algorithm])
-> (Algorithm -> Algorithm -> Algorithm -> [Algorithm])
-> Enum Algorithm
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: Algorithm -> Algorithm
succ :: Algorithm -> Algorithm
$cpred :: Algorithm -> Algorithm
pred :: Algorithm -> Algorithm
$ctoEnum :: Int -> Algorithm
toEnum :: Int -> Algorithm
$cfromEnum :: Algorithm -> Int
fromEnum :: Algorithm -> Int
$cenumFrom :: Algorithm -> [Algorithm]
enumFrom :: Algorithm -> [Algorithm]
$cenumFromThen :: Algorithm -> Algorithm -> [Algorithm]
enumFromThen :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromTo :: Algorithm -> Algorithm -> [Algorithm]
enumFromTo :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
enumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
Enum, Eq Algorithm
Eq Algorithm
-> (Algorithm -> Algorithm -> Ordering)
-> (Algorithm -> Algorithm -> Bool)
-> (Algorithm -> Algorithm -> Bool)
-> (Algorithm -> Algorithm -> Bool)
-> (Algorithm -> Algorithm -> Bool)
-> (Algorithm -> Algorithm -> Algorithm)
-> (Algorithm -> Algorithm -> Algorithm)
-> Ord Algorithm
Algorithm -> Algorithm -> Bool
Algorithm -> Algorithm -> Ordering
Algorithm -> Algorithm -> Algorithm
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Algorithm -> Algorithm -> Ordering
compare :: Algorithm -> Algorithm -> Ordering
$c< :: Algorithm -> Algorithm -> Bool
< :: Algorithm -> Algorithm -> Bool
$c<= :: Algorithm -> Algorithm -> Bool
<= :: Algorithm -> Algorithm -> Bool
$c> :: Algorithm -> Algorithm -> Bool
> :: Algorithm -> Algorithm -> Bool
$c>= :: Algorithm -> Algorithm -> Bool
>= :: Algorithm -> Algorithm -> Bool
$cmax :: Algorithm -> Algorithm -> Algorithm
max :: Algorithm -> Algorithm -> Algorithm
$cmin :: Algorithm -> Algorithm -> Algorithm
min :: Algorithm -> Algorithm -> Algorithm
Ord, Int -> Algorithm -> ShowS
[Algorithm] -> ShowS
Algorithm -> String
(Int -> Algorithm -> ShowS)
-> (Algorithm -> String)
-> ([Algorithm] -> ShowS)
-> Show Algorithm
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Algorithm -> ShowS
showsPrec :: Int -> Algorithm -> ShowS
$cshow :: Algorithm -> String
show :: Algorithm -> String
$cshowList :: [Algorithm] -> ShowS
showList :: [Algorithm] -> ShowS
Show, (forall x. Algorithm -> Rep Algorithm x)
-> (forall x. Rep Algorithm x -> Algorithm) -> Generic Algorithm
forall x. Rep Algorithm x -> Algorithm
forall x. Algorithm -> Rep Algorithm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Algorithm -> Rep Algorithm x
from :: forall x. Algorithm -> Rep Algorithm x
$cto :: forall x. Rep Algorithm x -> Algorithm
to :: forall x. Rep Algorithm x -> Algorithm
Generic, Typeable Algorithm
Typeable Algorithm
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Algorithm -> c Algorithm)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Algorithm)
-> (Algorithm -> Constr)
-> (Algorithm -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Algorithm))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm))
-> ((forall b. Data b => b -> b) -> Algorithm -> Algorithm)
-> (forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> Algorithm -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> Algorithm -> r)
-> (forall u. (forall d. Data d => d -> u) -> Algorithm -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> Algorithm -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Algorithm -> m Algorithm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Algorithm -> m Algorithm)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Algorithm -> m Algorithm)
-> Data Algorithm
Algorithm -> Constr
Algorithm -> DataType
(forall b. Data b => b -> b) -> Algorithm -> Algorithm
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Algorithm -> u
forall u. (forall d. Data d => d -> u) -> Algorithm -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Algorithm
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Algorithm)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm)
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Algorithm
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Algorithm
$ctoConstr :: Algorithm -> Constr
toConstr :: Algorithm -> Constr
$cdataTypeOf :: Algorithm -> DataType
dataTypeOf :: Algorithm -> DataType
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Algorithm)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Algorithm)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm)
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm)
$cgmapT :: (forall b. Data b => b -> b) -> Algorithm -> Algorithm
gmapT :: (forall b. Data b => b -> b) -> Algorithm -> Algorithm
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Algorithm -> [u]
gmapQ :: forall u. (forall d. Data d => d -> u) -> Algorithm -> [u]
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Algorithm -> u
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Algorithm -> u
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
Data, Typeable, Algorithm
Algorithm -> Algorithm -> Bounded Algorithm
forall a. a -> a -> Bounded a
$cminBound :: Algorithm
minBound :: Algorithm
$cmaxBound :: Algorithm
maxBound :: Algorithm
Bounded)
instance Hashable Algorithm

algorithm :: Algorithm -> CInt
algorithm :: Algorithm -> CInt
algorithm Algorithm
DefaultAlgorithm = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pwhash_alg_default
algorithm Algorithm
Argon2i13        = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pwhash_alg_argon2i13
algorithm Algorithm
Argon2id13       = Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
pwhash_alg_argon2id13

-- | Lets libsodium pick a hashing algorithm
pwhash_alg_default :: Int
pwhash_alg_default :: Int
pwhash_alg_default = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_alg_default
-- | version 1.3 of the Argon2i algorithm
pwhash_alg_argon2i13 :: Int
pwhash_alg_argon2i13 :: Int
pwhash_alg_argon2i13 = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_alg_argon2i13
-- | version 1.3 of the Argon2id algorithm
pwhash_alg_argon2id13 :: Int
pwhash_alg_argon2id13 :: Int
pwhash_alg_argon2id13 = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_alg_argon2id13

-- | Constants for the default algorithm
-- | Minimum output length for key derivation (16 (128 bits)).
pwhash_bytes_min :: Int
pwhash_bytes_min :: Int
pwhash_bytes_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_bytes_min
-- | Maximum output length for key derivation.
pwhash_bytes_max :: Int
pwhash_bytes_max :: Int
pwhash_bytes_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_bytes_max

-- | Minimum allowed memory limit for password hashing
pwhash_memlimit_min :: Int
pwhash_memlimit_min :: Int
pwhash_memlimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_memlimit_min
-- | Maximum allowed memory limit for password hashing
pwhash_memlimit_max :: Int
pwhash_memlimit_max :: Int
pwhash_memlimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_memlimit_max
-- | Constant for currently 64MB memory
pwhash_memlimit_interactive :: Int
pwhash_memlimit_interactive :: Int
pwhash_memlimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_memlimit_interactive
-- | Constant for currently 256MB memory
pwhash_memlimit_moderate :: Int
pwhash_memlimit_moderate :: Int
pwhash_memlimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_memlimit_moderate
-- | Constant for currently 1024MB memory
pwhash_memlimit_sensitive :: Int
pwhash_memlimit_sensitive :: Int
pwhash_memlimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_memlimit_sensitive

-- | Minimum allowed number of computations for password hashing
pwhash_opslimit_min :: Int
pwhash_opslimit_min :: Int
pwhash_opslimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_opslimit_min
-- | Maximum allowed number of computations for password hashing
pwhash_opslimit_max :: Int
pwhash_opslimit_max :: Int
pwhash_opslimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_opslimit_max

-- | Constant for relatively fast hashing
pwhash_opslimit_interactive :: Int
pwhash_opslimit_interactive :: Int
pwhash_opslimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_opslimit_interactive
-- | Constant for moderately fast hashing
pwhash_opslimit_moderate :: Int
pwhash_opslimit_moderate :: Int
pwhash_opslimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_opslimit_moderate
-- | Constant for relatively slow hashing
pwhash_opslimit_sensitive :: Int
pwhash_opslimit_sensitive :: Int
pwhash_opslimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_opslimit_sensitive

-- | Minimum number of characters in password for key derivation
pwhash_passwd_min :: Int
pwhash_passwd_min :: Int
pwhash_passwd_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_passwd_min
-- | Maximum number of characters in password for key derivation
pwhash_passwd_max :: Int
pwhash_passwd_max :: Int
pwhash_passwd_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_passwd_max

-- | Size of salt
pwhash_saltbytes :: Int
pwhash_saltbytes :: Int
pwhash_saltbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_saltbytes
-- | (Maximum) size of password hashing output
pwhash_strbytes :: Int
pwhash_strbytes :: Int
pwhash_strbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_strbytes
-- string that hashes with this algorithm are prefixed with
pwhash_strprefix :: Int
pwhash_strprefix :: Int
pwhash_strprefix = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_strprefix


-- | Constants for Argon2ID
-- | Minimum output length for key derivation (= 16 (128 bits)).
pwhash_argon2id_bytes_min :: Int
pwhash_argon2id_bytes_min :: Int
pwhash_argon2id_bytes_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_bytes_min
-- | Maximum output length for key derivation.
pwhash_argon2id_bytes_max :: Int
pwhash_argon2id_bytes_max :: Int
pwhash_argon2id_bytes_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_bytes_max

-- | Minimum allowed memory limit for password hashing
pwhash_argon2id_memlimit_min :: Int
pwhash_argon2id_memlimit_min :: Int
pwhash_argon2id_memlimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_memlimit_min
-- | Maximum allowed memory limit for password hashing
pwhash_argon2id_memlimit_max :: Int
pwhash_argon2id_memlimit_max :: Int
pwhash_argon2id_memlimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_memlimit_max
-- | Constant for currently 64MB memory
pwhash_argon2id_memlimit_interactive :: Int
pwhash_argon2id_memlimit_interactive :: Int
pwhash_argon2id_memlimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_memlimit_interactive
-- | Constant for currently 256MB memory
pwhash_argon2id_memlimit_moderate :: Int
pwhash_argon2id_memlimit_moderate :: Int
pwhash_argon2id_memlimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_memlimit_moderate
-- | Constant for currently 1024MB memory
pwhash_argon2id_memlimit_sensitive :: Int
pwhash_argon2id_memlimit_sensitive :: Int
pwhash_argon2id_memlimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_memlimit_sensitive

-- | Minimum allowed number of computations for password hashing
pwhash_argon2id_opslimit_min :: Int
pwhash_argon2id_opslimit_min :: Int
pwhash_argon2id_opslimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_opslimit_min
-- | Maximum allowed number of computations for password hashing
pwhash_argon2id_opslimit_max :: Int
pwhash_argon2id_opslimit_max :: Int
pwhash_argon2id_opslimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_opslimit_max

-- | Constant for relatively fast hashing
pwhash_argon2id_opslimit_interactive :: Int
pwhash_argon2id_opslimit_interactive :: Int
pwhash_argon2id_opslimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_opslimit_interactive
-- | Constant for moderately fast hashing
pwhash_argon2id_opslimit_moderate :: Int
pwhash_argon2id_opslimit_moderate :: Int
pwhash_argon2id_opslimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_opslimit_moderate
-- | Constant for relatively slow hashing
pwhash_argon2id_opslimit_sensitive :: Int
pwhash_argon2id_opslimit_sensitive :: Int
pwhash_argon2id_opslimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_opslimit_sensitive

-- | Minimum number of characters in password for key derivation
pwhash_argon2id_passwd_min :: Int
pwhash_argon2id_passwd_min :: Int
pwhash_argon2id_passwd_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_passwd_min
-- | Maximum number of characters in password for key derivation
pwhash_argon2id_passwd_max :: Int
pwhash_argon2id_passwd_max :: Int
pwhash_argon2id_passwd_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_passwd_max

-- | Size of salt
pwhash_argon2id_saltbytes :: Int
pwhash_argon2id_saltbytes :: Int
pwhash_argon2id_saltbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_saltbytes
-- | (Maximum) size of password hashing output
pwhash_argon2id_strbytes :: Int
pwhash_argon2id_strbytes :: Int
pwhash_argon2id_strbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_strbytes
-- string that hashes with this algorithm are prefixed with
pwhash_argon2id_strprefix :: Int
pwhash_argon2id_strprefix :: Int
pwhash_argon2id_strprefix = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2id_strprefix

-- | Constants for ARGON2I
-- | Minimum output length for key derivation (= 16 (128 bits)).
pwhash_argon2i_bytes_min :: Int
pwhash_argon2i_bytes_min :: Int
pwhash_argon2i_bytes_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_bytes_min
-- | Maximum output length for key derivation.
pwhash_argon2i_bytes_max :: Int
pwhash_argon2i_bytes_max :: Int
pwhash_argon2i_bytes_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_bytes_max

-- | Minimum allowed memory limit for password hashing
pwhash_argon2i_memlimit_min :: Int
pwhash_argon2i_memlimit_min :: Int
pwhash_argon2i_memlimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_memlimit_min
-- | Maximum allowed memory limit for password hashing
pwhash_argon2i_memlimit_max :: Int
pwhash_argon2i_memlimit_max :: Int
pwhash_argon2i_memlimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_memlimit_max
-- | Constant for currently 64MB memory
pwhash_argon2i_memlimit_interactive :: Int
pwhash_argon2i_memlimit_interactive :: Int
pwhash_argon2i_memlimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_memlimit_interactive
-- | Constant for currently 256MB memory
pwhash_argon2i_memlimit_moderate :: Int
pwhash_argon2i_memlimit_moderate :: Int
pwhash_argon2i_memlimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_memlimit_moderate
-- | Constant for currently 1024MB memory
pwhash_argon2i_memlimit_sensitive :: Int
pwhash_argon2i_memlimit_sensitive :: Int
pwhash_argon2i_memlimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_memlimit_sensitive

-- | Minimum allowed number of computations for password hashing
pwhash_argon2i_opslimit_min :: Int
pwhash_argon2i_opslimit_min :: Int
pwhash_argon2i_opslimit_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_opslimit_min
-- | Maximum allowed number of computations for password hashing
pwhash_argon2i_opslimit_max :: Int
pwhash_argon2i_opslimit_max :: Int
pwhash_argon2i_opslimit_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_opslimit_max

-- | Constant for relatively fast hashing
pwhash_argon2i_opslimit_interactive :: Int
pwhash_argon2i_opslimit_interactive :: Int
pwhash_argon2i_opslimit_interactive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_opslimit_interactive
-- | Constant for moderately fast hashing
pwhash_argon2i_opslimit_moderate :: Int
pwhash_argon2i_opslimit_moderate :: Int
pwhash_argon2i_opslimit_moderate = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_opslimit_moderate
-- | Constant for relatively slow hashing
pwhash_argon2i_opslimit_sensitive :: Int
pwhash_argon2i_opslimit_sensitive :: Int
pwhash_argon2i_opslimit_sensitive = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_opslimit_sensitive

-- | Minimum number of characters in password for key derivation
pwhash_argon2i_passwd_min :: Int
pwhash_argon2i_passwd_min :: Int
pwhash_argon2i_passwd_min = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_passwd_min
-- | Maximum number of characters in password for key derivation
pwhash_argon2i_passwd_max :: Int
pwhash_argon2i_passwd_max :: Int
pwhash_argon2i_passwd_max = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_passwd_max

-- | Size of salt
pwhash_argon2i_saltbytes :: Int
pwhash_argon2i_saltbytes :: Int
pwhash_argon2i_saltbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_saltbytes
-- | (Maximum) size of password hashing output
pwhash_argon2i_strbytes :: Int
pwhash_argon2i_strbytes :: Int
pwhash_argon2i_strbytes = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_strbytes
-- string that hashes with this algorithm are prefixed with
pwhash_argon2i_strprefix :: Int
pwhash_argon2i_strprefix :: Int
pwhash_argon2i_strprefix = CSize -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CSize
c_crypto_pwhash_argon2i_strprefix



foreign import ccall "crypto_pwhash"
  c_pwhash
        :: Ptr CChar
        -- ^ Derived key output buffer
        -> CULLong
        -- ^ Derived key length
        -> Ptr CChar
        -- ^ Password input buffer
        -> CULLong
        -- ^ Password length
        -> Ptr CChar
        -- ^ Salt input buffer
        -> CULLong
        -- ^ Operation limit
        -> CSize
        -- ^ Memory usage limit
        -> CInt
        -- ^ Algorithm
        -> IO CInt

foreign import ccall "crypto_pwhash_str"
  c_pwhash_str
        :: Ptr CChar
        -- ^ Hashed password output buffer
        -> Ptr CChar
        -- ^ Password input buffer
        -> CULLong
        -- ^ Password length
        -> CULLong
        -- ^ Operation limit
        -> CSize
        -- ^ Memory usage limit
        -> IO CInt

foreign import ccall "crypto_pwhash_str_verify"
  c_pwhash_str_verify
        :: Ptr CChar
        -- ^ Hashed password input buffer
        -> Ptr CChar
        -- ^ Password input buffer
        -> CULLong
        -- ^ Password length
        -> IO CInt

foreign import ccall "crypto_pwhash_str_needs_rehash"
  c_pwhash_str_needs_rehash
        :: Ptr CChar
        -- ^ Hashed password input buffer
        -> CULLong
        -- ^ Operation limit
        -> CSize
        -- ^ Memory usage limit
        -> IO CInt

foreign import ccall "crypto_pwhash_alg_argon2id13"
  c_crypto_pwhash_alg_argon2id13 :: CSize

foreign import ccall "crypto_pwhash_alg_argon2i13"
  c_crypto_pwhash_alg_argon2i13 :: CSize

foreign import ccall "crypto_pwhash_alg_default"
  c_crypto_pwhash_alg_default :: CSize

-- Constants for the default algorithm
foreign import ccall "crypto_pwhash_bytes_min"
  c_crypto_pwhash_bytes_min :: CSize

foreign import ccall "crypto_pwhash_bytes_max"
  c_crypto_pwhash_bytes_max :: CSize

foreign import ccall "crypto_pwhash_memlimit_min"
  c_crypto_pwhash_memlimit_min :: CSize

foreign import ccall "crypto_pwhash_memlimit_max"
  c_crypto_pwhash_memlimit_max :: CSize

foreign import ccall "crypto_pwhash_memlimit_interactive"
  c_crypto_pwhash_memlimit_interactive :: CSize

foreign import ccall "crypto_pwhash_memlimit_moderate"
  c_crypto_pwhash_memlimit_moderate :: CSize

foreign import ccall "crypto_pwhash_memlimit_sensitive"
  c_crypto_pwhash_memlimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_opslimit_min"
  c_crypto_pwhash_opslimit_min :: CSize

foreign import ccall "crypto_pwhash_opslimit_max"
  c_crypto_pwhash_opslimit_max :: CSize

foreign import ccall "crypto_pwhash_opslimit_interactive"
  c_crypto_pwhash_opslimit_interactive :: CSize

foreign import ccall "crypto_pwhash_opslimit_moderate"
  c_crypto_pwhash_opslimit_moderate :: CSize

foreign import ccall "crypto_pwhash_opslimit_sensitive"
  c_crypto_pwhash_opslimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_passwd_min"
  c_crypto_pwhash_passwd_min :: CSize

foreign import ccall "crypto_pwhash_passwd_max"
  c_crypto_pwhash_passwd_max :: CSize

foreign import ccall "crypto_pwhash_saltbytes"
  c_crypto_pwhash_saltbytes :: CSize

foreign import ccall "crypto_pwhash_strbytes"
  c_crypto_pwhash_strbytes :: CSize

foreign import ccall "crypto_pwhash_strprefix"
  c_crypto_pwhash_strprefix :: CSize

-- Constants for ARGON2ID (currently default)
foreign import ccall "crypto_pwhash_argon2id_bytes_min"
  c_crypto_pwhash_argon2id_bytes_min :: CSize

foreign import ccall "crypto_pwhash_argon2id_bytes_max"
  c_crypto_pwhash_argon2id_bytes_max :: CSize

foreign import ccall "crypto_pwhash_argon2id_memlimit_min"
  c_crypto_pwhash_argon2id_memlimit_min :: CSize

foreign import ccall "crypto_pwhash_argon2id_memlimit_max"
  c_crypto_pwhash_argon2id_memlimit_max :: CSize

foreign import ccall "crypto_pwhash_argon2id_memlimit_interactive"
  c_crypto_pwhash_argon2id_memlimit_interactive :: CSize

foreign import ccall "crypto_pwhash_argon2id_memlimit_moderate"
  c_crypto_pwhash_argon2id_memlimit_moderate :: CSize

foreign import ccall "crypto_pwhash_argon2id_memlimit_sensitive"
  c_crypto_pwhash_argon2id_memlimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_argon2id_opslimit_min"
  c_crypto_pwhash_argon2id_opslimit_min :: CSize

foreign import ccall "crypto_pwhash_argon2id_opslimit_max"
  c_crypto_pwhash_argon2id_opslimit_max :: CSize

foreign import ccall "crypto_pwhash_argon2id_opslimit_interactive"
  c_crypto_pwhash_argon2id_opslimit_interactive :: CSize

foreign import ccall "crypto_pwhash_argon2id_opslimit_moderate"
  c_crypto_pwhash_argon2id_opslimit_moderate :: CSize

foreign import ccall "crypto_pwhash_argon2id_opslimit_sensitive"
  c_crypto_pwhash_argon2id_opslimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_argon2id_passwd_min"
  c_crypto_pwhash_argon2id_passwd_min :: CSize

foreign import ccall "crypto_pwhash_argon2id_passwd_max"
  c_crypto_pwhash_argon2id_passwd_max :: CSize

foreign import ccall "crypto_pwhash_argon2id_saltbytes"
  c_crypto_pwhash_argon2id_saltbytes :: CSize

foreign import ccall "crypto_pwhash_argon2id_strbytes"
  c_crypto_pwhash_argon2id_strbytes :: CSize

foreign import ccall "crypto_pwhash_argon2id_strprefix"
  c_crypto_pwhash_argon2id_strprefix :: CSize


-- Constants for ARGON2I
foreign import ccall "crypto_pwhash_argon2i_bytes_min"
  c_crypto_pwhash_argon2i_bytes_min :: CSize

foreign import ccall "crypto_pwhash_argon2i_bytes_max"
  c_crypto_pwhash_argon2i_bytes_max :: CSize

foreign import ccall "crypto_pwhash_argon2i_memlimit_min"
  c_crypto_pwhash_argon2i_memlimit_min :: CSize

foreign import ccall "crypto_pwhash_argon2i_memlimit_max"
  c_crypto_pwhash_argon2i_memlimit_max :: CSize

foreign import ccall "crypto_pwhash_argon2i_memlimit_interactive"
  c_crypto_pwhash_argon2i_memlimit_interactive :: CSize

foreign import ccall "crypto_pwhash_argon2i_memlimit_moderate"
  c_crypto_pwhash_argon2i_memlimit_moderate :: CSize

foreign import ccall "crypto_pwhash_argon2i_memlimit_sensitive"
  c_crypto_pwhash_argon2i_memlimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_argon2i_opslimit_min"
  c_crypto_pwhash_argon2i_opslimit_min :: CSize

foreign import ccall "crypto_pwhash_argon2i_opslimit_max"
  c_crypto_pwhash_argon2i_opslimit_max :: CSize

foreign import ccall "crypto_pwhash_argon2i_opslimit_interactive"
  c_crypto_pwhash_argon2i_opslimit_interactive :: CSize

foreign import ccall "crypto_pwhash_argon2i_opslimit_moderate"
  c_crypto_pwhash_argon2i_opslimit_moderate :: CSize

foreign import ccall "crypto_pwhash_argon2i_opslimit_sensitive"
  c_crypto_pwhash_argon2i_opslimit_sensitive :: CSize

foreign import ccall "crypto_pwhash_argon2i_passwd_min"
  c_crypto_pwhash_argon2i_passwd_min :: CSize

foreign import ccall "crypto_pwhash_argon2i_passwd_max"
  c_crypto_pwhash_argon2i_passwd_max :: CSize

foreign import ccall "crypto_pwhash_argon2i_saltbytes"
  c_crypto_pwhash_argon2i_saltbytes :: CSize

foreign import ccall "crypto_pwhash_argon2i_strbytes"
  c_crypto_pwhash_argon2i_strbytes :: CSize

foreign import ccall "crypto_pwhash_argon2i_strprefix"
  c_crypto_pwhash_argon2i_strprefix :: CSize