sha256

Pure Haskell SHA-256, HMAC-SHA256 (docs.ppad.tech/sha256).
git clone git://git.ppad.tech/sha256.git
Log | Files | Refs | README | LICENSE

commit 5c1cbfef5875e05597cbdf0509c5257cfbc1724b
parent 47c928d2825597be888412ca812533eedaa020e2
Author: Jared Tobin <jared@jtobin.io>
Date:   Sun,  1 Feb 2026 13:53:56 +0400

lib: post-refactor dead code cleanup

Diffstat:
Mlib/Crypto/Hash/SHA256.hs | 25-------------------------
Mlib/Crypto/Hash/SHA256/Arm.hs | 47-----------------------------------------------
Mlib/Crypto/Hash/SHA256/Internal.hs | 16----------------
3 files changed, 0 insertions(+), 88 deletions(-)

diff --git a/lib/Crypto/Hash/SHA256.hs b/lib/Crypto/Hash/SHA256.hs @@ -124,31 +124,6 @@ _hmac k m = in update rs1 block {-# INLINABLE _hmac #-} --- XX these need testing - -_hmac_rm - :: Registers -- ^ key - -> BS.ByteString -- ^ message - -> Registers -_hmac_rm k m - | Arm.sha256_arm_available = Arm.hmac_rm k m - | otherwise = - let !key = pad_registers k - in _hmac key m -{-# INLINABLE _hmac_rm #-} - -_hmac_rr - :: Registers -- ^ key - -> Registers -- ^ message - -> Registers -_hmac_rr k m - | Arm.sha256_arm_available = Arm.hmac_rr k m - | otherwise = - let !key = pad_registers k - !block = pad_registers_with_length m - in _hmac_bb key block -{-# INLINABLE _hmac_rr #-} - _hmac_bb :: Block -- ^ key -> Block -- ^ message diff --git a/lib/Crypto/Hash/SHA256/Arm.hs b/lib/Crypto/Hash/SHA256/Arm.hs @@ -93,24 +93,6 @@ update rp bp block = do c_sha256_block rp bp {-# INLINE update #-} -data BoxedRegisters = BoxedRegisters !Registers - -update_pure :: Registers -> Block -> Registers -update_pure r b = - let !(BoxedRegisters rs) = _update r b - in rs -{-# INLINE update_pure #-} - -_update :: Registers -> Block -> BoxedRegisters -_update r b = unsafeDupablePerformIO $ - allocaBytes 32 $ \rp -> - allocaBytes 64 $ \bp -> do - poke_registers rp r - poke_block bp b - c_sha256_block rp bp - pure (BoxedRegisters (peek_registers rp)) -{-# INLINE _update #-} - -- api ----------------------------------------------------------------------- -- | Are ARM +sha2 extensions available? @@ -223,35 +205,6 @@ _hmac_bb rp bp k m = do update rp bp inner {-# INLINABLE _hmac_bb #-} -hmac_rm :: Registers -> BS.ByteString -> Registers -hmac_rm k m = - let !(BoxedRegisters rs) = _hmac_rm k m - in rs -{-# INLINABLE hmac_rm #-} - -_hmac_rm :: Registers -> BS.ByteString -> BoxedRegisters -_hmac_rm k m = unsafeDupablePerformIO $ - allocaBytes 32 $ \rp -> - allocaBytes 64 $ \bp -> do - let !key = pad_registers k - _hmac rp bp key m - pure (BoxedRegisters (peek_registers rp)) -{-# INLINABLE _hmac_rm #-} - -hmac_rr :: Registers -> Registers -> Registers -hmac_rr k m = - let !(BoxedRegisters rs) = _hmac_rr_pure k m - in rs -{-# INLINABLE hmac_rr #-} - -_hmac_rr_pure :: Registers -> Registers -> BoxedRegisters -_hmac_rr_pure k m = unsafeDupablePerformIO $ - allocaBytes 32 $ \rp -> - allocaBytes 64 $ \bp -> do - _hmac_rr rp bp k m - pure (BoxedRegisters (peek_registers rp)) -{-# INLINABLE _hmac_rr_pure #-} - -- | HMAC(key, v || sep || data) using ARM crypto extensions. -- Writes result to destination pointer. _hmac_rsb diff --git a/lib/Crypto/Hash/SHA256/Internal.hs b/lib/Crypto/Hash/SHA256/Internal.hs @@ -30,7 +30,6 @@ module Crypto.Hash.SHA256.Internal ( -- * Serializing , cat , cat_into - , cat_into32 -- * Hash function internals , update @@ -529,21 +528,6 @@ cat :: Registers -> BS.ByteString cat rs = BI.unsafeCreate 32 (cat_into rs) {-# INLINABLE cat #-} --- | Serialize SHA256 state to a pointer of word32's (big-endian). -cat_into32 :: Registers -> Ptr Word32 -> IO () -cat_into32 (R h0 h1 h2 h3 h4 h5 h6 h7) (Ptr addr) = GHC.IO.IO $ \s0 -> - case Exts.writeWord32OffAddr# addr 0# h0 s0 of { s1 -> - case Exts.writeWord32OffAddr# addr 1# h1 s1 of { s2 -> - case Exts.writeWord32OffAddr# addr 2# h2 s2 of { s3 -> - case Exts.writeWord32OffAddr# addr 3# h3 s3 of { s4 -> - case Exts.writeWord32OffAddr# addr 4# h4 s4 of { s5 -> - case Exts.writeWord32OffAddr# addr 5# h5 s5 of { s6 -> - case Exts.writeWord32OffAddr# addr 6# h6 s6 of { s7 -> - case Exts.writeWord32OffAddr# addr 7# h7 s7 of { s8 -> - (# s8, () #) - }}}}}}}} -{-# INLINE cat_into32 #-} - -- | Serialize SHA256 state to a pointer (big-endian). cat_into :: Registers -> Ptr Word8 -> IO () cat_into (R h0 h1 h2 h3 h4 h5 h6 h7) (Ptr addr) = GHC.IO.IO $ \s0 ->