Copyright | Copyright © 2021 Lars Kuhtz <lakuhtz@gmail.com> |
---|---|
License | MIT |
Maintainer | Lars Kuhtz <lakuhtz@gmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Bindings for OpenSSL EVP Message Digest Routines
Synopsis
- newtype Algorithm = Algorithm (Ptr Void)
- newtype Ctx a = Ctx (ForeignPtr Void)
- newtype Digest a = Digest ShortByteString
- resetCtx :: Ctx a -> IO ()
- initCtx :: Algorithm -> IO (Ctx a)
- updateCtx :: Ctx a -> Ptr Word8 -> Int -> IO ()
- finalCtx :: Ctx a -> IO (Digest a)
- class OpenSslDigest a where
- newtype OpenSslException = OpenSslException String
- newtype Sha2_224 = Sha2_224 ShortByteString
- newtype Sha2_256 = Sha2_256 ShortByteString
- newtype Sha2_384 = Sha2_384 ShortByteString
- newtype Sha2_512 = Sha2_512 ShortByteString
- newtype Sha2_512_224 = Sha2_512_224 ShortByteString
- newtype Sha2_512_256 = Sha2_512_256 ShortByteString
- newtype Sha3_224 = Sha3_224 ShortByteString
- newtype Sha3_256 = Sha3_256 ShortByteString
- newtype Sha3_384 = Sha3_384 ShortByteString
- newtype Sha3_512 = Sha3_512 ShortByteString
- newtype Shake128 = Shake128 ShortByteString
- newtype Shake256 = Shake256 ShortByteString
- newtype Keccak256 = Keccak256 ShortByteString
- newtype Keccak512 = Keccak512 ShortByteString
- finalizeKeccak256Ptr :: Ctx Keccak256 -> Ptr Word8 -> IO ()
- finalizeKeccak512Ptr :: Ctx Keccak512 -> Ptr Word8 -> IO ()
- newtype Blake2b512 = Blake2b512 ShortByteString
- newtype Blake2s256 = Blake2s256 ShortByteString
EVP digest routines
Instances
Show (Digest a) Source # | |
Eq (Digest a) Source # | |
Ord (Digest a) Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest a => Hash (Digest a) Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest a => IncrementalHash (Digest a) Source # | |
OpenSslDigest a => ResetableHash (Digest a) Source # | |
type Context (Digest a) Source # | |
Defined in Data.Hash.Internal.OpenSSL |
initCtx :: Algorithm -> IO (Ctx a) Source #
Allocates and initializes a new context. The context may be reused by
calling resetCtx
on it.
Algorithms
class OpenSslDigest a where Source #
Instances
OpenSslDigest Blake2b512 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Blake2s256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_224 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_384 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_512 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_512_224 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha2_512_256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha3_224 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha3_256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha3_384 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Sha3_512 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Shake128 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
OpenSslDigest Shake256 Source # | |
Defined in Data.Hash.Internal.OpenSSL |
newtype OpenSslException Source #
Instances
Exception OpenSslException Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
Show OpenSslException Source # | |
Defined in Data.Hash.Internal.OpenSSL showsPrec :: Int -> OpenSslException -> ShowS # show :: OpenSslException -> String # showList :: [OpenSslException] -> ShowS # |
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
Instances
Instances
Instances
Instances
newtype Sha2_512_224 Source #
Instances
newtype Sha2_512_256 Source #
Instances
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
Instances
Instances
Instances
Instances
Instances
Instances
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.
Instances
Show Keccak256 Source # | |
Eq Keccak256 Source # | |
Ord Keccak256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
Hash Keccak256 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
IncrementalHash Keccak256 Source # | |
ResetableHash Keccak256 Source # | |
type Context Keccak256 Source # | |
Defined in Data.Hash.Internal.OpenSSL |
Instances
Show Keccak512 Source # | |
Eq Keccak512 Source # | |
Ord Keccak512 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
Hash Keccak512 Source # | |
Defined in Data.Hash.Internal.OpenSSL | |
IncrementalHash Keccak512 Source # | |
ResetableHash Keccak512 Source # | |
type Context Keccak512 Source # | |
Defined in Data.Hash.Internal.OpenSSL |
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 #
Instances
newtype Blake2s256 Source #