diff options
Diffstat (limited to 'Crypto/Cipher/ThomasToVincent.hs')
-rw-r--r-- | Crypto/Cipher/ThomasToVincent.hs | 24 |
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 #-} | ||
2 | module Crypto.Cipher.ThomasToVincent where | ||
3 | |||
4 | import Crypto.Cipher.Types | ||
5 | import Data.Byteable | ||
6 | |||
7 | import Data.Tagged | ||
8 | import qualified Crypto.Classes as Thomas | ||
9 | |||
10 | newtype ThomasToVincent b = ThomasToVincent b | ||
11 | |||
12 | instance 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 | |||
19 | instance 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 | |||