cryptonite-0.30: 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 Source #

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

Instances details

Read Options Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods readsPrec :: Int -> ReadS Options Source # readList :: ReadS [Options] Source # readPrec :: ReadPrec Options Source # readListPrec :: ReadPrec [Options] Source #
Show Options Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods showsPrec :: Int -> Options -> ShowS Source # show :: Options -> String Source # showList :: [Options] -> ShowS Source #
Eq Options Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods (==) :: Options -> Options -> Bool Source # (/=) :: Options -> Options -> Bool Source #
Ord Options Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods compare :: Options -> Options -> Ordering Source # (<) :: Options -> Options -> Bool Source # (<=) :: Options -> Options -> Bool Source # (>) :: Options -> Options -> Bool Source # (>=) :: Options -> Options -> Bool Source # max :: Options -> Options -> Options Source # min :: Options -> Options -> Options Source #

type TimeCost = Word32 Source #

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 Source #

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

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

type Parallelism = Word32 Source #

A parallelism degree, which defines the number of parallel threads.

`ARGON2_MIN_LANES` <= `hashParallelism` <= `ARGON2_MAX_LANES` && `ARGON_MIN_THREADS` <= `hashParallelism` <= `ARGON2_MAX_THREADS`

data Variant Source #

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

Constructors

Argon2d | Argon2d is faster than Argon2i and uses data-depending memory access, which makes it suitable for cryptocurrencies and applications with no threats from side-channel timing attacks.
Argon2i | 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.
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

Instances details

Bounded Variant Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods minBound :: Variant Source # maxBound :: Variant Source #
Enum Variant Source # |

Instance details

Defined in Crypto.KDF.Argon2

Methods

succ :: Variant -> Variant Source #

pred :: Variant -> Variant Source #

toEnum :: Int -> Variant Source #

fromEnum :: Variant -> Int Source #

enumFrom :: Variant -> [Variant] Source #

enumFromThen :: Variant -> Variant -> [Variant] Source #

enumFromTo :: Variant -> Variant -> [Variant] Source #

enumFromThenTo :: Variant -> Variant -> Variant -> [Variant] Source #

Read Variant Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods readsPrec :: Int -> ReadS Variant Source # readList :: ReadS [Variant] Source # readPrec :: ReadPrec Variant Source # readListPrec :: ReadPrec [Variant] Source #
Show Variant Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods showsPrec :: Int -> Variant -> ShowS Source # show :: Variant -> String Source # showList :: [Variant] -> ShowS Source #
Eq Variant Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods (==) :: Variant -> Variant -> Bool Source # (/=) :: Variant -> Variant -> Bool Source #
Ord Variant Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods compare :: Variant -> Variant -> Ordering Source # (<) :: Variant -> Variant -> Bool Source # (<=) :: Variant -> Variant -> Bool Source # (>) :: Variant -> Variant -> Bool Source # (>=) :: Variant -> Variant -> Bool Source # max :: Variant -> Variant -> Variant Source # min :: Variant -> Variant -> Variant Source #

data Version Source #

Which version of Argon2 to use

Constructors

Version10 |
Version13 |

#### Instances

Instances details

Bounded Version Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods minBound :: Version Source # maxBound :: Version Source #
Enum Version Source # |

Instance details

Defined in Crypto.KDF.Argon2

Methods

succ :: Version -> Version Source #

pred :: Version -> Version Source #

toEnum :: Int -> Version Source #

fromEnum :: Version -> Int Source #

enumFrom :: Version -> [Version] Source #

enumFromThen :: Version -> Version -> [Version] Source #

enumFromTo :: Version -> Version -> [Version] Source #

enumFromThenTo :: Version -> Version -> Version -> [Version] Source #

Read Version Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods readsPrec :: Int -> ReadS Version Source # readList :: ReadS [Version] Source # readPrec :: ReadPrec Version Source # readListPrec :: ReadPrec [Version] Source #
Show Version Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods showsPrec :: Int -> Version -> ShowS Source # show :: Version -> String Source # showList :: [Version] -> ShowS Source #
Eq Version Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods (==) :: Version -> Version -> Bool Source # (/=) :: Version -> Version -> Bool Source #
Ord Version Source # |
Instance details Defined in Crypto.KDF.Argon2 Methods compare :: Version -> Version -> Ordering Source # (<) :: Version -> Version -> Bool Source # (<=) :: Version -> Version -> Bool Source # (>) :: Version -> Version -> Bool Source # (>=) :: Version -> Version -> Bool Source # max :: Version -> Version -> Version Source # min :: Version -> Version -> Version Source #

defaultOptions :: Options Source #

# Hashing function

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