Crypto.KDF.Argon2

cryptonite-0.22: Cryptography Primitives sink

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | unknown
Safe Haskell | None
Language | Haskell2010

Crypto.KDF.Argon2

Contents

- Hashing function

Description

Argon2 hashing function (P-H-C winner)

Recommended to use this module qualified

File started from Argon2.hs, from Oliver Charles at https://github.com/ocharles/argon2

Synopsis

- data Options = Options {
  - iterations :: !TimeCost
  - memory :: !MemoryCost
  - parallelism :: !Parallelism
  - variant :: !Variant
  - version :: !Version
  }
- type TimeCost = Word32
- type MemoryCost = Word32
- type Parallelism = Word32
- data Variant
  - = Argon2d
  - | Argon2i
  - | Argon2id
- data Version
  - = Version10
  - | Version13
- defaultOptions :: Options
- hash :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out) => Options -> password -> salt -> Int -> CryptoFailable out

# Documentation

data Options #

Parameters that can be adjusted to change the runtime performance of the hashing.

Constructors

Options |
Fields iterations :: !TimeCost memory :: !MemoryCost parallelism :: !Parallelism variant :: !Variant Which variant of Argon2 to use. version :: !Version Which version of Argon2 to use.

Instances

Eq Options # |
Methods (==) :: Options -> Options -> Bool # (/=) :: Options -> Options -> Bool #
Ord Options # |
Methods compare :: Options -> Options -> Ordering # (<) :: Options -> Options -> Bool # (<=) :: Options -> Options -> Bool # (>) :: Options -> Options -> Bool # (>=) :: Options -> Options -> Bool # max :: Options -> Options -> Options # min :: Options -> Options -> Options #
Read Options # |
Methods readsPrec :: Int -> ReadS Options # readList :: ReadS [Options] # readPrec :: ReadPrec Options # readListPrec :: ReadPrec [Options] #
Show Options # |
Methods showsPrec :: Int -> Options -> ShowS # show :: Options -> String # showList :: [Options] -> ShowS #

type TimeCost = Word32 #

The time cost, which defines the amount of computation realized and therefore the execution time, given in number of iterations.

`ARGON2_MIN_TIME` <= `hashIterations` <= `ARGON2_MAX_TIME`

type MemoryCost = Word32 #

The memory cost, which defines the memory usage, given in kibibytes.

max `ARGON2_MIN_MEMORY` (8 * `hashParallelism`) <= `hashMemory` <= `ARGON2_MAX_MEMORY`

type Parallelism = Word32 #

data Variant #

Which variant of Argon2 to use. You should choose the variant that is most applicable to your intention to hash inputs.

Constructors

Argon2d | Argon2i uses data-independent memory access, which is preferred for password hashing and password-based key derivation. Argon2i is slower as it makes more passes over the memory to protect from tradeoff attacks.
Argon2i | Argon2d is faster and uses data-depending memory access, which makes it suitable for cryptocurrencies and applications with no threats from side-channel timing attacks.
Argon2id | Argon2id is a hybrid of Argon2i and Argon2d, using a combination of data-depending and data-independent memory accesses, which gives some of Argon2i's resistance to side-channel cache timing attacks and much of Argon2d's resistance to GPU cracking attacks

Instances

Bounded Variant # |
Methods minBound :: Variant # maxBound :: Variant #
Enum Variant # |
Methods succ :: Variant -> Variant # pred :: Variant -> Variant # toEnum :: Int -> Variant # fromEnum :: Variant -> Int # enumFrom :: Variant -> [Variant] # enumFromThen :: Variant -> Variant -> [Variant] # enumFromTo :: Variant -> Variant -> [Variant] # enumFromThenTo :: Variant -> Variant -> Variant -> [Variant] #
Eq Variant # |
Methods (==) :: Variant -> Variant -> Bool # (/=) :: Variant -> Variant -> Bool #
Ord Variant # |
Methods compare :: Variant -> Variant -> Ordering # (<) :: Variant -> Variant -> Bool # (<=) :: Variant -> Variant -> Bool # (>) :: Variant -> Variant -> Bool # (>=) :: Variant -> Variant -> Bool # max :: Variant -> Variant -> Variant # min :: Variant -> Variant -> Variant #
Read Variant # |
Methods readsPrec :: Int -> ReadS Variant # readList :: ReadS [Variant] # readPrec :: ReadPrec Variant # readListPrec :: ReadPrec [Variant] #
Show Variant # |
Methods showsPrec :: Int -> Variant -> ShowS # show :: Variant -> String # showList :: [Variant] -> ShowS #

data Version #

Which version of Argon2 to use

Constructors

Version10 |
Version13 |

Instances

Bounded Version # |
Methods minBound :: Version # maxBound :: Version #
Enum Version # |
Methods succ :: Version -> Version # pred :: Version -> Version # toEnum :: Int -> Version # fromEnum :: Version -> Int # enumFrom :: Version -> [Version] # enumFromThen :: Version -> Version -> [Version] # enumFromTo :: Version -> Version -> [Version] # enumFromThenTo :: Version -> Version -> Version -> [Version] #
Eq Version # |
Methods (==) :: Version -> Version -> Bool # (/=) :: Version -> Version -> Bool #
Ord Version # |
Methods compare :: Version -> Version -> Ordering # (<) :: Version -> Version -> Bool # (<=) :: Version -> Version -> Bool # (>) :: Version -> Version -> Bool # (>=) :: Version -> Version -> Bool # max :: Version -> Version -> Version # min :: Version -> Version -> Version #
Read Version # |
Methods readsPrec :: Int -> ReadS Version # readList :: ReadS [Version] # readPrec :: ReadPrec Version # readListPrec :: ReadPrec [Version] #
Show Version # |
Methods showsPrec :: Int -> Version -> ShowS # show :: Version -> String # showList :: [Version] -> ShowS #

defaultOptions :: Options #

# Hashing function

hash :: (ByteArrayAccess password, ByteArrayAccess salt, ByteArray out) => Options -> password -> salt -> Int -> CryptoFailable out #