diff --git a/Crypto/ConstructHash/MiyaguchiPreneel.hs b/Crypto/ConstructHash/MiyaguchiPreneel.hs index 1e7a051..795e989 100644 --- a/Crypto/ConstructHash/MiyaguchiPreneel.hs +++ b/Crypto/ConstructHash/MiyaguchiPreneel.hs @@ -10,7 +10,7 @@ -- {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Crypto.ConstructHash.MiyaguchiPreneel - ( mp, mp' + ( compute, compute' , MiyaguchiPreneel ) where @@ -30,11 +30,11 @@ instance Eq (MiyaguchiPreneel a) where -- | Compute Miyaguchi-Preneel one way compress using the supplied block cipher. -mp' :: (ByteArrayAccess bin, BlockCipher cipher) - => (Bytes -> cipher) -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size - -> bin -- ^ input message - -> MiyaguchiPreneel cipher -- ^ output tag -mp' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . B.convert +compute' :: (ByteArrayAccess bin, BlockCipher cipher) + => (Bytes -> cipher) -- ^ key build function to compute Miyaguchi-Preneel. care about block-size and key-size + -> bin -- ^ input message + -> MiyaguchiPreneel cipher -- ^ output tag +compute' g = MP . foldl' (step $ g) (B.replicate bsz 0) . chunks . B.convert where bsz = blockSize ( g B.empty {- dummy to get block size -} ) 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. -- -- Simple usage /mp' msg :: MiyaguchiPreneel AES128/ -mp :: (ByteArrayAccess bin, BlockCipher cipher) - => bin -- ^ input message - -> MiyaguchiPreneel cipher -- ^ output tag -mp = mp' $ throwCryptoError . cipherInit +compute :: (ByteArrayAccess bin, BlockCipher cipher) + => bin -- ^ input message + -> MiyaguchiPreneel cipher -- ^ output tag +compute = compute' $ throwCryptoError . cipherInit -- | computation step of Miyaguchi-Preneel step :: (ByteArray ba, BlockCipher k) diff --git a/tests/KAT_MiyaguchiPreneel.hs b/tests/KAT_MiyaguchiPreneel.hs index 8634b32..163e434 100644 --- a/tests/KAT_MiyaguchiPreneel.hs +++ b/tests/KAT_MiyaguchiPreneel.hs @@ -2,7 +2,7 @@ module KAT_MiyaguchiPreneel (tests) where import Crypto.Cipher.AES (AES128) -import Crypto.ConstructHash.MiyaguchiPreneel +import Crypto.ConstructHash.MiyaguchiPreneel as MiyaguchiPreneel import Imports @@ -13,7 +13,7 @@ import Data.ByteArray.Encoding (Base (Base16), convertFromBase) runMP128 :: ByteString -> ByteString -runMP128 s = B.convert (mp s :: MiyaguchiPreneel AES128) +runMP128 s = B.convert (MiyaguchiPreneel.compute s :: MiyaguchiPreneel AES128) hxs :: String -> ByteString hxs = either (error . ("hxs:" ++)) id . convertFromBase Base16