{-# 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
min :: Salt -> Salt -> Salt
$cmin :: Salt -> Salt -> Salt
max :: Salt -> Salt -> Salt
$cmax :: Salt -> Salt -> Salt
>= :: Salt -> Salt -> Bool
$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
compare :: Salt -> Salt -> Ordering
$ccompare :: Salt -> Salt -> Ordering
$cp1Ord :: Eq Salt
Ord, Typeable Salt
DataType
Constr
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 -> DataType
Salt -> Constr
(forall b. Data b => b -> b) -> Salt -> Salt
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cSalt :: Constr
$tSalt :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> Salt -> m Salt
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Salt -> m Salt
gmapQi :: Int -> (forall d. Data d => d -> u) -> Salt -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Salt -> u
gmapQ :: (forall d. Data d => d -> u) -> Salt -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Salt -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Salt -> r
gmapT :: (forall b. Data b => b -> b) -> Salt -> Salt
$cgmapT :: (forall b. Data b => b -> b) -> Salt -> Salt
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Salt)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Salt)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Salt)
dataTypeOf :: Salt -> DataType
$cdataTypeOf :: Salt -> DataType
toConstr :: Salt -> Constr
$ctoConstr :: Salt -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Salt
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Salt
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Salt -> c Salt
$cp1Data :: Typeable 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
hash :: Salt -> Int
$chash :: Salt -> Int
hashWithSalt :: Int -> Salt -> Int
$chashWithSalt :: Int -> Salt -> Int
$cp1Hashable :: Eq Salt
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
$cto :: forall x. Rep Salt x -> Salt
$cfrom :: forall x. Salt -> Rep Salt x
Generic, Salt -> ()
(Salt -> ()) -> NFData Salt
forall a. (a -> ()) -> NFData a
rnf :: Salt -> ()
$crnf :: 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
min :: PasswordHash -> PasswordHash -> PasswordHash
$cmin :: PasswordHash -> PasswordHash -> PasswordHash
max :: PasswordHash -> PasswordHash -> PasswordHash
$cmax :: PasswordHash -> PasswordHash -> PasswordHash
>= :: PasswordHash -> PasswordHash -> Bool
$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
compare :: PasswordHash -> PasswordHash -> Ordering
$ccompare :: PasswordHash -> PasswordHash -> Ordering
$cp1Ord :: Eq PasswordHash
Ord, Typeable PasswordHash
DataType
Constr
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 -> DataType
PasswordHash -> Constr
(forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cPasswordHash :: Constr
$tPasswordHash :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> PasswordHash -> m PasswordHash
gmapQi :: Int -> (forall d. Data d => d -> u) -> PasswordHash -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> PasswordHash -> u
gmapQ :: (forall d. Data d => d -> u) -> PasswordHash -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> PasswordHash -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> PasswordHash -> r
gmapT :: (forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
$cgmapT :: (forall b. Data b => b -> b) -> PasswordHash -> PasswordHash
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PasswordHash)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c PasswordHash)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c PasswordHash)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c PasswordHash)
dataTypeOf :: PasswordHash -> DataType
$cdataTypeOf :: PasswordHash -> DataType
toConstr :: PasswordHash -> Constr
$ctoConstr :: PasswordHash -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PasswordHash
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c PasswordHash
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> PasswordHash -> c PasswordHash
$cp1Data :: Typeable 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
hash :: PasswordHash -> Int
$chash :: PasswordHash -> Int
hashWithSalt :: Int -> PasswordHash -> Int
$chashWithSalt :: Int -> PasswordHash -> Int
$cp1Hashable :: Eq PasswordHash
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
$cto :: forall x. Rep PasswordHash x -> PasswordHash
$cfrom :: forall x. PasswordHash -> Rep PasswordHash x
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
showList :: [PasswordHash] -> ShowS
$cshowList :: [PasswordHash] -> ShowS
show :: PasswordHash -> String
$cshow :: PasswordHash -> String
showsPrec :: Int -> PasswordHash -> ShowS
$cshowsPrec :: Int -> PasswordHash -> ShowS
Show, PasswordHash -> ()
(PasswordHash -> ()) -> NFData PasswordHash
forall a. (a -> ()) -> NFData a
rnf :: PasswordHash -> ()
$crnf :: 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
/= :: Opslimit -> Opslimit -> Bool
$c/= :: Opslimit -> Opslimit -> Bool
== :: Opslimit -> Opslimit -> Bool
$c== :: 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
min :: Opslimit -> Opslimit -> Opslimit
$cmin :: Opslimit -> Opslimit -> Opslimit
max :: Opslimit -> Opslimit -> Opslimit
$cmax :: Opslimit -> Opslimit -> Opslimit
>= :: Opslimit -> Opslimit -> Bool
$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
compare :: Opslimit -> Opslimit -> Ordering
$ccompare :: Opslimit -> Opslimit -> Ordering
$cp1Ord :: Eq Opslimit
Ord, Typeable Opslimit
DataType
Constr
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 -> DataType
Opslimit -> Constr
(forall b. Data b => b -> b) -> Opslimit -> Opslimit
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cOpslimit :: Constr
$tOpslimit :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Opslimit -> m Opslimit
gmapQi :: Int -> (forall d. Data d => d -> u) -> Opslimit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Opslimit -> u
gmapQ :: (forall d. Data d => d -> u) -> Opslimit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Opslimit -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Opslimit -> r
gmapT :: (forall b. Data b => b -> b) -> Opslimit -> Opslimit
$cgmapT :: (forall b. Data b => b -> b) -> Opslimit -> Opslimit
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Opslimit)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Opslimit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Opslimit)
dataTypeOf :: Opslimit -> DataType
$cdataTypeOf :: Opslimit -> DataType
toConstr :: Opslimit -> Constr
$ctoConstr :: Opslimit -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Opslimit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Opslimit
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Opslimit -> c Opslimit
$cp1Data :: Typeable 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
hash :: Opslimit -> Int
$chash :: Opslimit -> Int
hashWithSalt :: Int -> Opslimit -> Int
$chashWithSalt :: Int -> Opslimit -> Int
$cp1Hashable :: Eq Opslimit
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
$cto :: forall x. Rep Opslimit x -> Opslimit
$cfrom :: forall x. Opslimit -> Rep Opslimit x
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
showList :: [Opslimit] -> ShowS
$cshowList :: [Opslimit] -> ShowS
show :: Opslimit -> String
$cshow :: Opslimit -> String
showsPrec :: Int -> Opslimit -> ShowS
$cshowsPrec :: Int -> Opslimit -> ShowS
Show, Opslimit -> ()
(Opslimit -> ()) -> NFData Opslimit
forall a. (a -> ()) -> NFData a
rnf :: Opslimit -> ()
$crnf :: 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
/= :: Memlimit -> Memlimit -> Bool
$c/= :: Memlimit -> Memlimit -> Bool
== :: Memlimit -> Memlimit -> Bool
$c== :: 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
min :: Memlimit -> Memlimit -> Memlimit
$cmin :: Memlimit -> Memlimit -> Memlimit
max :: Memlimit -> Memlimit -> Memlimit
$cmax :: Memlimit -> Memlimit -> Memlimit
>= :: Memlimit -> Memlimit -> Bool
$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
compare :: Memlimit -> Memlimit -> Ordering
$ccompare :: Memlimit -> Memlimit -> Ordering
$cp1Ord :: Eq Memlimit
Ord, Typeable Memlimit
DataType
Constr
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 -> DataType
Memlimit -> Constr
(forall b. Data b => b -> b) -> Memlimit -> Memlimit
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cMemlimit :: Constr
$tMemlimit :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Memlimit -> m Memlimit
gmapQi :: Int -> (forall d. Data d => d -> u) -> Memlimit -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Memlimit -> u
gmapQ :: (forall d. Data d => d -> u) -> Memlimit -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Memlimit -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Memlimit -> r
gmapT :: (forall b. Data b => b -> b) -> Memlimit -> Memlimit
$cgmapT :: (forall b. Data b => b -> b) -> Memlimit -> Memlimit
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Memlimit)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Memlimit)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Memlimit)
dataTypeOf :: Memlimit -> DataType
$cdataTypeOf :: Memlimit -> DataType
toConstr :: Memlimit -> Constr
$ctoConstr :: Memlimit -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Memlimit
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Memlimit
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Memlimit -> c Memlimit
$cp1Data :: Typeable 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
hash :: Memlimit -> Int
$chash :: Memlimit -> Int
hashWithSalt :: Int -> Memlimit -> Int
$chashWithSalt :: Int -> Memlimit -> Int
$cp1Hashable :: Eq Memlimit
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
$cto :: forall x. Rep Memlimit x -> Memlimit
$cfrom :: forall x. Memlimit -> Rep Memlimit x
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
showList :: [Memlimit] -> ShowS
$cshowList :: [Memlimit] -> ShowS
show :: Memlimit -> String
$cshow :: Memlimit -> String
showsPrec :: Int -> Memlimit -> ShowS
$cshowsPrec :: Int -> Memlimit -> ShowS
Show, Memlimit -> ()
(Memlimit -> ()) -> NFData Memlimit
forall a. (a -> ()) -> NFData a
rnf :: Memlimit -> ()
$crnf :: 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
/= :: Policy -> Policy -> Bool
$c/= :: Policy -> Policy -> Bool
== :: Policy -> Policy -> Bool
$c== :: 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
min :: Policy -> Policy -> Policy
$cmin :: Policy -> Policy -> Policy
max :: Policy -> Policy -> Policy
$cmax :: Policy -> Policy -> Policy
>= :: Policy -> Policy -> Bool
$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
compare :: Policy -> Policy -> Ordering
$ccompare :: Policy -> Policy -> Ordering
$cp1Ord :: Eq Policy
Ord, Typeable Policy
DataType
Constr
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 -> DataType
Policy -> Constr
(forall b. Data b => b -> b) -> Policy -> Policy
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cPolicy :: Constr
$tPolicy :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> Policy -> m Policy
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Policy -> m Policy
gmapQi :: Int -> (forall d. Data d => d -> u) -> Policy -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Policy -> u
gmapQ :: (forall d. Data d => d -> u) -> Policy -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Policy -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Policy -> r
gmapT :: (forall b. Data b => b -> b) -> Policy -> Policy
$cgmapT :: (forall b. Data b => b -> b) -> Policy -> Policy
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Policy)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Policy)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Policy)
dataTypeOf :: Policy -> DataType
$cdataTypeOf :: Policy -> DataType
toConstr :: Policy -> Constr
$ctoConstr :: Policy -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Policy
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Policy
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Policy -> c Policy
$cp1Data :: Typeable 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
$cto :: forall x. Rep Policy x -> Policy
$cfrom :: forall x. Policy -> Rep Policy x
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
showList :: [Policy] -> ShowS
$cshowList :: [Policy] -> ShowS
show :: Policy -> String
$cshow :: Policy -> String
showsPrec :: Int -> Policy -> ShowS
$cshowsPrec :: Int -> 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
/= :: Algorithm -> Algorithm -> Bool
$c/= :: Algorithm -> Algorithm -> Bool
== :: Algorithm -> Algorithm -> Bool
$c== :: 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
enumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
$cenumFromThenTo :: Algorithm -> Algorithm -> Algorithm -> [Algorithm]
enumFromTo :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromTo :: Algorithm -> Algorithm -> [Algorithm]
enumFromThen :: Algorithm -> Algorithm -> [Algorithm]
$cenumFromThen :: Algorithm -> Algorithm -> [Algorithm]
enumFrom :: Algorithm -> [Algorithm]
$cenumFrom :: Algorithm -> [Algorithm]
fromEnum :: Algorithm -> Int
$cfromEnum :: Algorithm -> Int
toEnum :: Int -> Algorithm
$ctoEnum :: Int -> Algorithm
pred :: Algorithm -> Algorithm
$cpred :: Algorithm -> Algorithm
succ :: Algorithm -> Algorithm
$csucc :: 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
min :: Algorithm -> Algorithm -> Algorithm
$cmin :: Algorithm -> Algorithm -> Algorithm
max :: Algorithm -> Algorithm -> Algorithm
$cmax :: Algorithm -> Algorithm -> Algorithm
>= :: Algorithm -> Algorithm -> Bool
$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
compare :: Algorithm -> Algorithm -> Ordering
$ccompare :: Algorithm -> Algorithm -> Ordering
$cp1Ord :: Eq 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
showList :: [Algorithm] -> ShowS
$cshowList :: [Algorithm] -> ShowS
show :: Algorithm -> String
$cshow :: Algorithm -> String
showsPrec :: Int -> Algorithm -> ShowS
$cshowsPrec :: Int -> 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
$cto :: forall x. Rep Algorithm x -> Algorithm
$cfrom :: forall x. Algorithm -> Rep Algorithm x
Generic, Typeable Algorithm
DataType
Constr
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 -> DataType
Algorithm -> Constr
(forall b. Data b => b -> b) -> Algorithm -> Algorithm
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cArgon2id13 :: Constr
$cArgon2i13 :: Constr
$cDefaultAlgorithm :: Constr
$tAlgorithm :: DataType
gmapMo :: (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
gmapMp :: (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
gmapM :: (forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Algorithm -> m Algorithm
gmapQi :: Int -> (forall d. Data d => d -> u) -> Algorithm -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Algorithm -> u
gmapQ :: (forall d. Data d => d -> u) -> Algorithm -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Algorithm -> [u]
gmapQr :: (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
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Algorithm -> r
gmapT :: (forall b. Data b => b -> b) -> Algorithm -> Algorithm
$cgmapT :: (forall b. Data b => b -> b) -> Algorithm -> Algorithm
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Algorithm)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Algorithm)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Algorithm)
dataTypeOf :: Algorithm -> DataType
$cdataTypeOf :: Algorithm -> DataType
toConstr :: Algorithm -> Constr
$ctoConstr :: Algorithm -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Algorithm
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Algorithm
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Algorithm -> c Algorithm
$cp1Data :: Typeable Algorithm
Data, Typeable, Algorithm
Algorithm -> Algorithm -> Bounded Algorithm
forall a. a -> a -> Bounded a
maxBound :: Algorithm
$cmaxBound :: Algorithm
minBound :: Algorithm
$cminBound :: 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