From 3146e835f11acd05fa905f56e6c365023f6ae0d6 Mon Sep 17 00:00:00 2001 From: joe Date: Sat, 4 Jan 2014 16:44:20 -0500 Subject: ThomasToVincent adapter. --- Crypto/Cipher/ThomasToVincent.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Crypto/Cipher/ThomasToVincent.hs (limited to 'Crypto/Cipher/ThomasToVincent.hs') diff --git a/Crypto/Cipher/ThomasToVincent.hs b/Crypto/Cipher/ThomasToVincent.hs new file mode 100644 index 0000000..85b0875 --- /dev/null +++ b/Crypto/Cipher/ThomasToVincent.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE ScopedTypeVariables #-} +module Crypto.Cipher.ThomasToVincent where + +import Crypto.Cipher.Types +import Data.Byteable + +import Data.Tagged +import qualified Crypto.Classes as Thomas + +newtype ThomasToVincent b = ThomasToVincent b + +instance Thomas.BlockCipher b => Cipher (ThomasToVincent b) where + cipherName _ = "ThomasToVincent" + cipherInit k = ThomasToVincent b + where Just b = Thomas.buildKey (toBytes k) + cipherKeySize _ = KeySizeFixed (bitlen `div` 8) + where Tagged bitlen = Thomas.keyLength :: Tagged b Int + +instance Thomas.BlockCipher b => BlockCipher (ThomasToVincent b) where + blockSize _ = bitlen `div` 8 + where Tagged bitlen = Thomas.blockSize :: Tagged b Int + ecbEncrypt (ThomasToVincent k) = Thomas.ecb k + ecbDecrypt (ThomasToVincent k) = Thomas.unEcb k + -- cgit v1.2.3