summaryrefslogtreecommitdiff
path: root/Crypto/Cipher/ThomasToVincent.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Crypto/Cipher/ThomasToVincent.hs')
-rw-r--r--Crypto/Cipher/ThomasToVincent.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/Crypto/Cipher/ThomasToVincent.hs b/Crypto/Cipher/ThomasToVincent.hs
new file mode 100644
index 0000000..11cede3
--- /dev/null
+++ b/Crypto/Cipher/ThomasToVincent.hs
@@ -0,0 +1,35 @@
1{-# LANGUAGE CPP #-}
2{-# LANGUAGE ScopedTypeVariables #-}
3module Crypto.Cipher.ThomasToVincent where
4
5import Crypto.Cipher.Types
6import Data.Byteable
7
8import Data.Tagged
9import qualified Crypto.Classes as Thomas
10#if ! MIN_VERSION_crypto_api(0,11,0)
11import qualified Crypto.Modes as Thomas
12#endif
13
14
15newtype ThomasToVincent b = ThomasToVincent b
16
17instance Thomas.BlockCipher b => Cipher (ThomasToVincent b) where
18 cipherName _ = "ThomasToVincent"
19 cipherInit k = ThomasToVincent b
20 where Just b = Thomas.buildKey (toBytes k)
21 cipherKeySize _ = KeySizeFixed (bitlen `div` 8)
22 where Tagged bitlen = Thomas.keyLength :: Tagged b Int
23
24instance Thomas.BlockCipher b => BlockCipher (ThomasToVincent b) where
25 blockSize _ = bitlen `div` 8
26 where Tagged bitlen = Thomas.blockSize :: Tagged b Int
27#if ! MIN_VERSION_crypto_api(0,11,0)
28 ecbEncrypt (ThomasToVincent k) = Thomas.ecb' k
29 ecbDecrypt (ThomasToVincent k) = Thomas.unEcb' k
30#else
31 ecbEncrypt (ThomasToVincent k) = Thomas.ecb k
32 ecbDecrypt (ThomasToVincent k) = Thomas.unEcb k
33#endif
34
35