summaryrefslogtreecommitdiff
path: root/Crypto
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 /Crypto
parent4321065899a47b087d3e6f08f40706d6e45b4bae (diff)
ThomasToVincent adapter.
Diffstat (limited to 'Crypto')
-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