amazonka-core-1.6.1: Core data types and functionality for Amazonka libraries.

Copyright(c) 2013-2018 Brendan Hay
LicenseMozilla Public License, v. 2.0.
MaintainerBrendan Hay <brendan.g.hay+amazonka@gmail.com>
Stabilityprovisional
Portabilitynon-portable (GHC extensions)
Safe HaskellNone
LanguageHaskell2010

Network.AWS.Data.Crypto

Contents

Description

 
Synopsis

Conversion

Algorithms

hmacSHA1 :: (ByteArrayAccess a, ByteArray b) => a -> b -> HMAC SHA1 Source #

Apply an HMAC sha1 with the given secret to the given value.

Contexts

hash :: (ByteArrayAccess ba, HashAlgorithm a) => ba -> Digest a #

Hash a strict bytestring into a digest.

hashlazy :: HashAlgorithm a => ByteString -> Digest a #

Hash a lazy bytestring into a digest.

hashInit :: HashAlgorithm a => Context a #

Initialize a new context for this hash algorithm

hashUpdate :: (ByteArrayAccess ba, HashAlgorithm a) => Context a -> ba -> Context a #

run hashUpdates on one single bytestring and return the updated context.

hashFinalize :: HashAlgorithm a => Context a -> Digest a #

Finalize a context and return a digest.

Re-exported

data HMAC a #

Represent an HMAC that is a phantom type with the hash used to produce the mac.

The Eq instance is constant time.

Instances
Eq (HMAC a) 
Instance details

Defined in Crypto.MAC.HMAC

Methods

(==) :: HMAC a -> HMAC a -> Bool #

(/=) :: HMAC a -> HMAC a -> Bool #

ByteArrayAccess (HMAC a) 
Instance details

Defined in Crypto.MAC.HMAC

Methods

length :: HMAC a -> Int #

withByteArray :: HMAC a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: HMAC a -> Ptr p -> IO () #

data Digest a #

Represent a digest for a given hash algorithm.

This type is an instance of ByteArrayAccess from package memory. Module Data.ByteArray provides many primitives to work with those values including conversion to other types.

Creating a digest from a bytearray is also possible with function digestFromByteString.

Instances
Eq (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

(==) :: Digest a -> Digest a -> Bool #

(/=) :: Digest a -> Digest a -> Bool #

Ord (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

compare :: Digest a -> Digest a -> Ordering #

(<) :: Digest a -> Digest a -> Bool #

(<=) :: Digest a -> Digest a -> Bool #

(>) :: Digest a -> Digest a -> Bool #

(>=) :: Digest a -> Digest a -> Bool #

max :: Digest a -> Digest a -> Digest a #

min :: Digest a -> Digest a -> Digest a #

Show (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

showsPrec :: Int -> Digest a -> ShowS #

show :: Digest a -> String #

showList :: [Digest a] -> ShowS #

NFData (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

rnf :: Digest a -> () #

ByteArrayAccess (Digest a) 
Instance details

Defined in Crypto.Hash.Types

Methods

length :: Digest a -> Int #

withByteArray :: Digest a -> (Ptr p -> IO a0) -> IO a0 #

copyByteArrayToPtr :: Digest a -> Ptr p -> IO () #

ToText (Digest a) Source # 
Instance details

Defined in Network.AWS.Data.Text

Methods

toText :: Digest a -> Text Source #

class HashAlgorithm a #

Class representing hashing algorithms.

The interface presented here is update in place and lowlevel. the Hash module takes care of hidding the mutable interface properly.

Instances
HashAlgorithm Blake2b_160 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_224 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_256 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_384 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2b_512 
Instance details

Defined in Crypto.Hash.Blake2b

HashAlgorithm Blake2bp_512 
Instance details

Defined in Crypto.Hash.Blake2bp

HashAlgorithm Blake2s_160 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_224 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2s_256 
Instance details

Defined in Crypto.Hash.Blake2s

HashAlgorithm Blake2sp_224 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Blake2sp_256 
Instance details

Defined in Crypto.Hash.Blake2sp

HashAlgorithm Keccak_224 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_256 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_384 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm Keccak_512 
Instance details

Defined in Crypto.Hash.Keccak

HashAlgorithm MD2 
Instance details

Defined in Crypto.Hash.MD2

Associated Types

type HashBlockSize MD2 :: Nat #

type HashDigestSize MD2 :: Nat #

type HashInternalContextSize MD2 :: Nat #

HashAlgorithm MD4 
Instance details

Defined in Crypto.Hash.MD4

Associated Types

type HashBlockSize MD4 :: Nat #

type HashDigestSize MD4 :: Nat #

type HashInternalContextSize MD4 :: Nat #

HashAlgorithm MD5 
Instance details

Defined in Crypto.Hash.MD5

Associated Types

type HashBlockSize MD5 :: Nat #

type HashDigestSize MD5 :: Nat #

type HashInternalContextSize MD5 :: Nat #

HashAlgorithm RIPEMD160 
Instance details

Defined in Crypto.Hash.RIPEMD160

HashAlgorithm SHA1 
Instance details

Defined in Crypto.Hash.SHA1

HashAlgorithm SHA224 
Instance details

Defined in Crypto.Hash.SHA224

HashAlgorithm SHA256 
Instance details

Defined in Crypto.Hash.SHA256

HashAlgorithm SHA3_224 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_256 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_384 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA3_512 
Instance details

Defined in Crypto.Hash.SHA3

HashAlgorithm SHA384 
Instance details

Defined in Crypto.Hash.SHA384

HashAlgorithm SHA512 
Instance details

Defined in Crypto.Hash.SHA512

HashAlgorithm SHA512t_224 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm SHA512t_256 
Instance details

Defined in Crypto.Hash.SHA512t

HashAlgorithm Skein256_224 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein256_256 
Instance details

Defined in Crypto.Hash.Skein256

HashAlgorithm Skein512_224 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_256 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_384 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Skein512_512 
Instance details

Defined in Crypto.Hash.Skein512

HashAlgorithm Tiger 
Instance details

Defined in Crypto.Hash.Tiger

HashAlgorithm Whirlpool 
Instance details

Defined in Crypto.Hash.Whirlpool

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2s bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2s bitlen) :: Nat #

type HashDigestSize (Blake2s bitlen) :: Nat #

type HashInternalContextSize (Blake2s bitlen) :: Nat #

Methods

hashBlockSize :: Blake2s bitlen -> Int #

hashDigestSize :: Blake2s bitlen -> Int #

hashInternalContextSize :: Blake2s bitlen -> Int #

hashInternalInit :: Ptr (Context (Blake2s bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (Blake2s bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (Blake2s bitlen)) -> Ptr (Digest (Blake2s bitlen)) -> IO () #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2b bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2b bitlen) :: Nat #

type HashDigestSize (Blake2b bitlen) :: Nat #

type HashInternalContextSize (Blake2b bitlen) :: Nat #

Methods

hashBlockSize :: Blake2b bitlen -> Int #

hashDigestSize :: Blake2b bitlen -> Int #

hashInternalContextSize :: Blake2b bitlen -> Int #

hashInternalInit :: Ptr (Context (Blake2b bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (Blake2b bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (Blake2b bitlen)) -> Ptr (Digest (Blake2b bitlen)) -> IO () #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 256) => HashAlgorithm (Blake2sp bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2sp bitlen) :: Nat #

type HashDigestSize (Blake2sp bitlen) :: Nat #

type HashInternalContextSize (Blake2sp bitlen) :: Nat #

Methods

hashBlockSize :: Blake2sp bitlen -> Int #

hashDigestSize :: Blake2sp bitlen -> Int #

hashInternalContextSize :: Blake2sp bitlen -> Int #

hashInternalInit :: Ptr (Context (Blake2sp bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (Blake2sp bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (Blake2sp bitlen)) -> Ptr (Digest (Blake2sp bitlen)) -> IO () #

(IsDivisibleBy8 bitlen, KnownNat bitlen, IsAtLeast bitlen 8, IsAtMost bitlen 512) => HashAlgorithm (Blake2bp bitlen) 
Instance details

Defined in Crypto.Hash.Blake2

Associated Types

type HashBlockSize (Blake2bp bitlen) :: Nat #

type HashDigestSize (Blake2bp bitlen) :: Nat #

type HashInternalContextSize (Blake2bp bitlen) :: Nat #

Methods

hashBlockSize :: Blake2bp bitlen -> Int #

hashDigestSize :: Blake2bp bitlen -> Int #

hashInternalContextSize :: Blake2bp bitlen -> Int #

hashInternalInit :: Ptr (Context (Blake2bp bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (Blake2bp bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (Blake2bp bitlen)) -> Ptr (Digest (Blake2bp bitlen)) -> IO () #

(IsDivisibleBy8 bitlen, KnownNat bitlen) => HashAlgorithm (SHAKE128 bitlen) 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE128 bitlen) :: Nat #

type HashDigestSize (SHAKE128 bitlen) :: Nat #

type HashInternalContextSize (SHAKE128 bitlen) :: Nat #

Methods

hashBlockSize :: SHAKE128 bitlen -> Int #

hashDigestSize :: SHAKE128 bitlen -> Int #

hashInternalContextSize :: SHAKE128 bitlen -> Int #

hashInternalInit :: Ptr (Context (SHAKE128 bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (SHAKE128 bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (SHAKE128 bitlen)) -> Ptr (Digest (SHAKE128 bitlen)) -> IO () #

(IsDivisibleBy8 bitlen, KnownNat bitlen) => HashAlgorithm (SHAKE256 bitlen) 
Instance details

Defined in Crypto.Hash.SHAKE

Associated Types

type HashBlockSize (SHAKE256 bitlen) :: Nat #

type HashDigestSize (SHAKE256 bitlen) :: Nat #

type HashInternalContextSize (SHAKE256 bitlen) :: Nat #

Methods

hashBlockSize :: SHAKE256 bitlen -> Int #

hashDigestSize :: SHAKE256 bitlen -> Int #

hashInternalContextSize :: SHAKE256 bitlen -> Int #

hashInternalInit :: Ptr (Context (SHAKE256 bitlen)) -> IO () #

hashInternalUpdate :: Ptr (Context (SHAKE256 bitlen)) -> Ptr Word8 -> Word32 -> IO () #

hashInternalFinalize :: Ptr (Context (SHAKE256 bitlen)) -> Ptr (Digest (SHAKE256 bitlen)) -> IO () #

data SHA256 #

SHA256 cryptographic hash algorithm

Constructors

SHA256 
Instances
Data SHA256 
Instance details

Defined in Crypto.Hash.SHA256

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SHA256 -> c SHA256 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c SHA256 #

toConstr :: SHA256 -> Constr #

dataTypeOf :: SHA256 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c SHA256) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c SHA256) #

gmapT :: (forall b. Data b => b -> b) -> SHA256 -> SHA256 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SHA256 -> r #

gmapQ :: (forall d. Data d => d -> u) -> SHA256 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SHA256 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SHA256 -> m SHA256 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SHA256 -> m SHA256 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SHA256 -> m SHA256 #

Show SHA256 
Instance details

Defined in Crypto.Hash.SHA256

HashAlgorithm SHA256 
Instance details

Defined in Crypto.Hash.SHA256

type HashInternalContextSize SHA256 
Instance details

Defined in Crypto.Hash.SHA256

type HashDigestSize SHA256 
Instance details

Defined in Crypto.Hash.SHA256

type HashBlockSize SHA256 
Instance details

Defined in Crypto.Hash.SHA256

data MD5 #

MD5 cryptographic hash algorithm

Constructors

MD5 
Instances
Data MD5 
Instance details

Defined in Crypto.Hash.MD5

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MD5 -> c MD5 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c MD5 #

toConstr :: MD5 -> Constr #

dataTypeOf :: MD5 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c MD5) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c MD5) #

gmapT :: (forall b. Data b => b -> b) -> MD5 -> MD5 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MD5 -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MD5 -> r #

gmapQ :: (forall d. Data d => d -> u) -> MD5 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MD5 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MD5 -> m MD5 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MD5 -> m MD5 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MD5 -> m MD5 #

Show MD5 
Instance details

Defined in Crypto.Hash.MD5

Methods

showsPrec :: Int -> MD5 -> ShowS #

show :: MD5 -> String #

showList :: [MD5] -> ShowS #

HashAlgorithm MD5 
Instance details

Defined in Crypto.Hash.MD5

Associated Types

type HashBlockSize MD5 :: Nat #

type HashDigestSize MD5 :: Nat #

type HashInternalContextSize MD5 :: Nat #

type HashInternalContextSize MD5 
Instance details

Defined in Crypto.Hash.MD5

type HashDigestSize MD5 
Instance details

Defined in Crypto.Hash.MD5

type HashBlockSize MD5 
Instance details

Defined in Crypto.Hash.MD5

type HashBlockSize MD5 = 64

data Base #

The different bases that can be used.

See RFC4648 for details. In particular, Base64 can be standard or URL-safe. URL-safe encoding is often used in other specifications without padding characters.

Examples

A quick example to show the differences:

>>> let input = "Is 3 > 2?" :: ByteString
>>> let convertedTo base = convertToBase base input :: ByteString
>>> convertedTo Base16
"49732033203e20323f"
>>> convertedTo Base32
"JFZSAMZAHYQDEPY="
>>> convertedTo Base64
"SXMgMyA+IDI/"
>>> convertedTo Base64URLUnpadded
"SXMgMyA-IDI_"
>>> convertedTo Base64OpenBSD
"QVKeKw.8GBG9"

Constructors

Base16

similar to hexadecimal

Base32 
Base64

standard Base64

Base64URLUnpadded

unpadded URL-safe Base64

Base64OpenBSD

Base64 as used in OpenBSD password encoding (such as bcrypt)

Instances
Eq Base 
Instance details

Defined in Data.ByteArray.Encoding

Methods

(==) :: Base -> Base -> Bool #

(/=) :: Base -> Base -> Bool #

Show Base 
Instance details

Defined in Data.ByteArray.Encoding

Methods

showsPrec :: Int -> Base -> ShowS #

show :: Base -> String #

showList :: [Base] -> ShowS #