summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoe <joe@blackbird>2014-01-04 16:44:20 -0500
committerjoe <joe@blackbird>2014-01-04 16:44:20 -0500
commit3146e835f11acd05fa905f56e6c365023f6ae0d6 (patch)
tree7200ef3a1a352f44f9ebc647543342308db8dec3
parent4321065899a47b087d3e6f08f40706d6e45b4bae (diff)
ThomasToVincent adapter.
-rw-r--r--Crypto/Cipher/ThomasToVincent.hs24
-rw-r--r--cipher-cast5.cabal5
2 files changed, 27 insertions, 2 deletions
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 @@
1{-# LANGUAGE ScopedTypeVariables #-}
2module Crypto.Cipher.ThomasToVincent where
3
4import Crypto.Cipher.Types
5import Data.Byteable
6
7import Data.Tagged
8import qualified Crypto.Classes as Thomas
9
10newtype ThomasToVincent b = ThomasToVincent b
11
12instance Thomas.BlockCipher b => Cipher (ThomasToVincent b) where
13 cipherName _ = "ThomasToVincent"
14 cipherInit k = ThomasToVincent b
15 where Just b = Thomas.buildKey (toBytes k)
16 cipherKeySize _ = KeySizeFixed (bitlen `div` 8)
17 where Tagged bitlen = Thomas.keyLength :: Tagged b Int
18
19instance Thomas.BlockCipher b => BlockCipher (ThomasToVincent b) where
20 blockSize _ = bitlen `div` 8
21 where Tagged bitlen = Thomas.blockSize :: Tagged b Int
22 ecbEncrypt (ThomasToVincent k) = Thomas.ecb k
23 ecbDecrypt (ThomasToVincent k) = Thomas.unEcb k
24
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
16 16
17library 17library
18 exposed-modules: Crypto.Cipher.Feistel, Crypto.Cipher.Cast5, 18 exposed-modules: Crypto.Cipher.Feistel, Crypto.Cipher.Cast5,
19 Crypto.Cipher.SBox 19 Crypto.Cipher.SBox, Crypto.Cipher.ThomasToVincent
20 -- other-modules: 20 -- other-modules:
21 build-depends: base >= 4.5, bytestring >=0.9, binary >=0.5.1.1, cpu ==0.1.*, 21 build-depends: base >= 4.5, bytestring >=0.9, binary >=0.5.1.1, cpu ==0.1.*,
22 vector >=0.9, crypto-api ==0.12.*, cereal ==0.3.*, 22 vector >=0.9, crypto-api ==0.12.*, cereal ==0.3.*,
23 tagged ==0.6.*, template-haskell >=2.7, 23 tagged ==0.6.*, template-haskell >=2.7,
24 ghc-prim >= 0.2, primitive >= 0.4 24 ghc-prim >= 0.2, primitive >= 0.4, crypto-cipher-types,
25 byteable