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 ++++++++++++++++++++++++ cipher-cast5.cabal | 5 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 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 + diff --git a/cipher-cast5.cabal b/cipher-cast5.cabal index 383a813..fd44ea3 100644 --- a/cipher-cast5.cabal +++ b/cipher-cast5.cabal @@ -16,9 +16,10 @@ cabal-version: >=1.8 library exposed-modules: Crypto.Cipher.Feistel, Crypto.Cipher.Cast5, - Crypto.Cipher.SBox + Crypto.Cipher.SBox, Crypto.Cipher.ThomasToVincent -- other-modules: build-depends: base >= 4.5, bytestring >=0.9, binary >=0.5.1.1, cpu ==0.1.*, vector >=0.9, crypto-api ==0.12.*, cereal ==0.3.*, tagged ==0.6.*, template-haskell >=2.7, - ghc-prim >= 0.2, primitive >= 0.4 + ghc-prim >= 0.2, primitive >= 0.4, crypto-cipher-types, + byteable -- cgit v1.2.3