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.hs24
1 files changed, 24 insertions, 0 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