hashes-0.2.3: Hash functions
CopyrightCopyright © 2021 Lars Kuhtz <lakuhtz@gmail.com>
LicenseMIT
MaintainerLars Kuhtz <lakuhtz@gmail.com>
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Data.Hash.Internal.OpenSSL

Description

Bindings for OpenSSL EVP Message Digest Routines

Synopsis

EVP digest routines

newtype Algorithm Source #

Constructors

Algorithm (Ptr Void) 

newtype Ctx a Source #

Constructors

Ctx (ForeignPtr Void) 

newtype Digest a Source #

Constructors

Digest ShortByteString 

Instances

Instances details
Show (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Methods

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

show :: Digest a -> String #

showList :: [Digest a] -> ShowS #

Eq (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Methods

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

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

Ord (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

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 #

OpenSslDigest a => Hash (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest a => IncrementalHash (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Associated Types

type Context (Digest a) Source #

Methods

update :: Context (Digest a) -> Ptr Word8 -> Int -> IO () Source #

finalize :: Context (Digest a) -> IO (Digest a) Source #

OpenSslDigest a => ResetableHash (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Methods

reset :: Context (Digest a) -> IO () Source #

type Context (Digest a) Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

type Context (Digest a) = Ctx a

resetCtx :: Ctx a -> IO () Source #

Resets a context an initialize context.

initCtx :: Algorithm -> IO (Ctx a) Source #

Allocates and initializes a new context. The context may be reused by calling resetCtx on it.

updateCtx :: Ctx a -> Ptr Word8 -> Int -> IO () Source #

Feed more data into an context.

finalCtx :: Ctx a -> IO (Digest a) Source #

Finalize a hash and return the digest.

Algorithms

class OpenSslDigest a where Source #

Instances

Instances details
OpenSslDigest Blake2b512 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Blake2s256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_384 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_512 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha3_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha3_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha3_384 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Sha3_512 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Shake128 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

OpenSslDigest Shake256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

SHA2

SHA-2 (Secure Hash Algorithm 2) is a family of cryptographic hash functions standardized in NIST FIPS 180-4, first published in 2001. These functions conform to NIST FIPS 180-4.

The following hash functions from the SHA-2 family are supported in openssl-3.0 (cf. https://www.openssl.org/docs/man3.0/man3/EVP_sha224.html)

EVP_sha224, EVP_sha256, EVP_sha512_224, EVP_sha512_256, EVP_sha384, EVP_sha512

newtype Sha2_512_224 Source #

Instances

Instances details
Show Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Eq Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Ord Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Hash Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

IncrementalHash Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Associated Types

type Context Sha2_512_224 Source #

OpenSslDigest Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

type Context Sha2_512_224 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

newtype Sha2_512_256 Source #

Instances

Instances details
Show Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Eq Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Ord Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Hash Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

IncrementalHash Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

Associated Types

type Context Sha2_512_256 Source #

OpenSslDigest Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

type Context Sha2_512_256 Source # 
Instance details

Defined in Data.Hash.Internal.OpenSSL

SHA3

SHA-3 (Secure Hash Algorithm 3) is a family of cryptographic hash functions standardized in NIST FIPS 202, first published in 2015. It is based on the Keccak algorithm. These functions conform to NIST FIPS 202.

The following hash functions from the SHA-3 family are supported in openssl-3.0 (cf. https://www.openssl.org/docs/man3.0/man3/EVP_sha3_224.html)

EVP_sha3_224, EVP_sha3_256, EVP_sha3_384, EVP_sha3_512, EVP_shake128, EVP_shake256

Keccak

This is the latest version of Keccak-256 hash function that was submitted to the SHA3 competition. It is different from the final NIST SHA3 hash.

The difference between NIST SHA3-256 and Keccak-256 is the use of a different padding character for the input message. The former uses '0x06' and the latter uses '0x01'.

This version of Keccak-256 is used by the Ethereum project.

This implementation of Keccak-256 uses internal OpenSSL APIs. It may break with new versions of OpenSSL. It may also be broken for existing versions of OpenSSL. Portability of the code is unknown.

ONLY USE THIS CODE AFTER YOU HAVE VERIFIED THAT IT WORKS WITH OUR VERSION OF OPENSSL.

For details see the file cbits/keccak.c.

Unsafe finalize functions

finalizeKeccak256Ptr :: Ctx Keccak256 -> Ptr Word8 -> IO () Source #

Low-Level function that writes the final digest directly into the provided pointer. The pointer must point to at least 64 bytes of allocated memory. This is not checked and a violation of this condition may result in a segmentation fault.

finalizeKeccak512Ptr :: Ctx Keccak512 -> Ptr Word8 -> IO () Source #

Low-Level function that writes the final digest directly into the provided pointer. The pointer must point to at least 64 bytes of allocated memory. This is not checked and a violation of this condition may result in a segmentation fault.

Blake2

BLAKE2 is an improved version of BLAKE, which was submitted to the NIST SHA-3 algorithm competition. The BLAKE2s and BLAKE2b algorithms are described in RFC 7693.

The following hash functions from the BLAKE2 family are supported in openssl-3.0 (cf. https://www.openssl.org/docs/man3.0/man3/EVP_blake2b512.html)

EVP_blake2b512, EVP_blake2s256

While the BLAKE2b and BLAKE2s algorithms supports a variable length digest, this implementation outputs a digest of a fixed length (the maximum length supported), which is 512-bits for BLAKE2b and 256-bits for BLAKE2s.

newtype Blake2b512 Source #

newtype Blake2s256 Source #