rename definitions which compute miyaguchi-preneel hash.
This commit is contained in:
parent
5e76b8af5f
commit
87867b49bc
@ -10,7 +10,7 @@
|
|||||||
--
|
--
|
||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||||
module Crypto.ConstructHash.MiyaguchiPreneel
|
module Crypto.ConstructHash.MiyaguchiPreneel
|
||||||
( mp, mp'
|
( compute, compute'
|
||||||
, MiyaguchiPreneel
|
, MiyaguchiPreneel
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -30,11 +30,11 @@ instance Eq (MiyaguchiPreneel a) where
|
|||||||
|
|
||||||
|
|
||||||
-- | Compute Miyaguchi-Preneel one way compress using the supplied block cipher.
|
-- | Compute Miyaguchi-Preneel one way compress using the supplied block cipher.
|
||||||
mp' :: (ByteArrayAccess bin, BlockCipher cipher)
|
compute' :: (ByteArrayAccess bin, BlockCipher cipher)
|
||||||
=> (Bytes -> cipher) -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size
|
=> (Bytes -> cipher) -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size
|
||||||
-> bin -- ^ input message
|
-> bin -- ^ input message
|
||||||
-> MiyaguchiPreneel cipher -- ^ output tag
|
-> MiyaguchiPreneel cipher -- ^ output tag
|
||||||
mp' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . B.convert
|
compute' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . B.convert
|
||||||
where
|
where
|
||||||
bsz = blockSize ( g B.empty {- dummy to get block size -} )
|
bsz = blockSize ( g B.empty {- dummy to get block size -} )
|
||||||
chunks msg
|
chunks msg
|
||||||
@ -47,10 +47,10 @@ mp' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . B.convert
|
|||||||
-- Only safe when KEY-SIZE equals to BLOCK-SIZE.
|
-- Only safe when KEY-SIZE equals to BLOCK-SIZE.
|
||||||
--
|
--
|
||||||
-- Simple usage /mp' msg :: MiyaguchiPreneel AES128/
|
-- Simple usage /mp' msg :: MiyaguchiPreneel AES128/
|
||||||
mp :: (ByteArrayAccess bin, BlockCipher cipher)
|
compute :: (ByteArrayAccess bin, BlockCipher cipher)
|
||||||
=> bin -- ^ input message
|
=> bin -- ^ input message
|
||||||
-> MiyaguchiPreneel cipher -- ^ output tag
|
-> MiyaguchiPreneel cipher -- ^ output tag
|
||||||
mp = mp' $ throwCryptoError . cipherInit
|
compute = compute' $ throwCryptoError . cipherInit
|
||||||
|
|
||||||
-- | computation step of Miyaguchi-Preneel
|
-- | computation step of Miyaguchi-Preneel
|
||||||
step :: (ByteArray ba, BlockCipher k)
|
step :: (ByteArray ba, BlockCipher k)
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
module KAT_MiyaguchiPreneel (tests) where
|
module KAT_MiyaguchiPreneel (tests) where
|
||||||
|
|
||||||
import Crypto.Cipher.AES (AES128)
|
import Crypto.Cipher.AES (AES128)
|
||||||
import Crypto.ConstructHash.MiyaguchiPreneel
|
import Crypto.ConstructHash.MiyaguchiPreneel as MiyaguchiPreneel
|
||||||
|
|
||||||
import Imports
|
import Imports
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ import Data.ByteArray.Encoding (Base (Base16), convertFromBase)
|
|||||||
|
|
||||||
|
|
||||||
runMP128 :: ByteString -> ByteString
|
runMP128 :: ByteString -> ByteString
|
||||||
runMP128 s = B.convert (mp s :: MiyaguchiPreneel AES128)
|
runMP128 s = B.convert (MiyaguchiPreneel.compute s :: MiyaguchiPreneel AES128)
|
||||||
|
|
||||||
hxs :: String -> ByteString
|
hxs :: String -> ByteString
|
||||||
hxs = either (error . ("hxs:" ++)) id . convertFromBase Base16
|
hxs = either (error . ("hxs:" ++)) id . convertFromBase Base16
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user