[hash] replace scrub by reset
reset make more sense as it leave the mutable context in a state where it can be re-used by further update, whereas scrub doesn't.
This commit is contained in:
parent
987f9e7bb6
commit
9794e2132b
@ -16,7 +16,7 @@ module Crypto.Hash.IO
|
||||
, hashMutableInitWith
|
||||
, hashMutableUpdate
|
||||
, hashMutableFinalize
|
||||
, hashMutableScrub
|
||||
, hashMutableReset
|
||||
) where
|
||||
|
||||
import Crypto.Hash.Types
|
||||
@ -56,6 +56,9 @@ hashMutableFinalize mc = doFinalize undefined (B.withByteArray mc) B.alloc
|
||||
hashInternalFinalize ctx dig
|
||||
return $ Digest b
|
||||
|
||||
-- FIXME not implemented just yet.
|
||||
hashMutableScrub :: HashAlgorithm a => MutableContext a -> IO ()
|
||||
hashMutableScrub (MutableContext _) = return ()
|
||||
-- | Reset the mutable context to the initial state of the hash
|
||||
hashMutableReset :: HashAlgorithm a => MutableContext a -> IO ()
|
||||
hashMutableReset mc = doReset mc (B.withByteArray mc)
|
||||
where
|
||||
doReset :: HashAlgorithm a => MutableContext a -> ((Ptr (Context a) -> IO ()) -> IO ()) -> IO ()
|
||||
doReset _ withCtx = withCtx hashInternalInit
|
||||
|
||||
@ -69,7 +69,7 @@ initialize secret = unsafeDoIO (doHashAlg undefined)
|
||||
ctx <- hashMutableInitWith alg
|
||||
hashMutableUpdate ctx secret
|
||||
digest <- hashMutableFinalize ctx
|
||||
hashMutableScrub ctx
|
||||
hashMutableReset ctx
|
||||
-- pad it if necessary
|
||||
if digestSize < blockSize
|
||||
then do
|
||||
|
||||
Loading…
Reference in New Issue
Block a user