{-# OPTIONS_HADDOCK prune #-}
module Crypto.Hash.SHA256 (
hash
, hash_prefixed
, Lazy.hash_lazy
, MAC(..)
, hmac
, Lazy.hmac_lazy
, _hmac_rr
, _hmac_rsb
) where
import qualified Data.ByteString as BS
import Data.Word (Word8, Word32)
import Foreign.Ptr (Ptr)
import qualified Crypto.Hash.SHA256.Native as Native
import Crypto.Hash.SHA256.Internal (MAC(..), Registers)
import qualified Crypto.Hash.SHA256.Lazy as Lazy
import qualified Crypto.Hash.SHA256.Pure as Pure
hash :: BS.ByteString -> BS.ByteString
hash :: ByteString -> ByteString
hash ByteString
m
| Bool
Native.sha256_native_available = ByteString -> ByteString
Native.hash ByteString
m
| Bool
otherwise = ByteString -> ByteString
Pure.hash ByteString
m
{-# INLINABLE hash #-}
hash_prefixed :: BS.ByteString -> BS.ByteString -> BS.ByteString
hash_prefixed :: ByteString -> ByteString -> ByteString
hash_prefixed ByteString
p ByteString
m
| Bool
Native.sha256_native_available = ByteString -> ByteString -> ByteString
Native.hash_prefixed ByteString
p ByteString
m
| Bool
otherwise = ByteString -> ByteString -> ByteString
Pure.hash_prefixed ByteString
p ByteString
m
{-# INLINABLE hash_prefixed #-}
hmac :: BS.ByteString -> BS.ByteString -> MAC
hmac :: ByteString -> ByteString -> MAC
hmac ByteString
k ByteString
m
| Bool
Native.sha256_native_available = ByteString -> MAC
MAC (ByteString -> ByteString -> ByteString
Native.hmac ByteString
k ByteString
m)
| Bool
otherwise = ByteString -> MAC
MAC (ByteString -> ByteString -> ByteString
Pure.hmac ByteString
k ByteString
m)
{-# INLINABLE hmac #-}
_hmac_rr
:: Ptr Word32
-> Ptr Word32
-> Registers
-> Registers
-> IO ()
_hmac_rr :: Ptr Word32 -> Ptr Word32 -> Registers -> Registers -> IO ()
_hmac_rr Ptr Word32
rp Ptr Word32
bp Registers
k Registers
m
| Bool
Native.sha256_native_available = Ptr Word32 -> Ptr Word32 -> Registers -> Registers -> IO ()
Native._hmac_rr Ptr Word32
rp Ptr Word32
bp Registers
k Registers
m
| Bool
otherwise = Ptr Word32 -> Ptr Word32 -> Registers -> Registers -> IO ()
Pure._hmac_rr Ptr Word32
rp Ptr Word32
bp Registers
k Registers
m
{-# INLINABLE _hmac_rr #-}
_hmac_rsb
:: Ptr Word32
-> Ptr Word32
-> Registers
-> Registers
-> Word8
-> BS.ByteString
-> IO ()
_hmac_rsb :: Ptr Word32
-> Ptr Word32
-> Registers
-> Registers
-> Word8
-> ByteString
-> IO ()
_hmac_rsb Ptr Word32
rp Ptr Word32
bp Registers
k Registers
v Word8
sep ByteString
dat
| Bool
Native.sha256_native_available = Ptr Word32
-> Ptr Word32
-> Registers
-> Registers
-> Word8
-> ByteString
-> IO ()
Native._hmac_rsb Ptr Word32
rp Ptr Word32
bp Registers
k Registers
v Word8
sep ByteString
dat
| Bool
otherwise = Ptr Word32
-> Ptr Word32
-> Registers
-> Registers
-> Word8
-> ByteString
-> IO ()
Pure._hmac_rsb Ptr Word32
rp Ptr Word32
bp Registers
k Registers
v Word8
sep ByteString
dat
{-# INLINABLE _hmac_rsb #-}