diff options
author | joe <joe@jerkface.net> | 2016-08-26 02:39:26 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2019-07-01 09:19:55 -0400 |
commit | f1a0772d5fb17f4460bdf996e06bb0983cf7a530 (patch) | |
tree | 43351e7b2411095e744512c0d1edfbeff4202174 /Crypto/Cipher/ThomasToVincent.hs | |
parent | 7909c13a18e260af68819be7444829f799cb7c38 (diff) |
Merge external cipher-cast5 code into this library.
Diffstat (limited to 'Crypto/Cipher/ThomasToVincent.hs')
-rw-r--r-- | Crypto/Cipher/ThomasToVincent.hs | 35 |
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 #-} | ||
3 | module Crypto.Cipher.ThomasToVincent where | ||
4 | |||
5 | import Crypto.Cipher.Types | ||
6 | import Data.Byteable | ||
7 | |||
8 | import Data.Tagged | ||
9 | import qualified Crypto.Classes as Thomas | ||
10 | #if ! MIN_VERSION_crypto_api(0,11,0) | ||
11 | import qualified Crypto.Modes as Thomas | ||
12 | #endif | ||
13 | |||
14 | |||
15 | newtype ThomasToVincent b = ThomasToVincent b | ||
16 | |||
17 | instance 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 | |||
24 | instance 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 | |||