1module Crypto.Cipher.Twofish
2    ( Twofish128
3    , Twofish192
4    , Twofish256
5    ) where
6
7import Crypto.Cipher.Twofish.Primitive
8import Crypto.Cipher.Types
9import Crypto.Cipher.Utils
10
11newtype Twofish128 = Twofish128 Twofish
12
13instance Cipher Twofish128 where
14    cipherName    _ = "Twofish128"
15    cipherKeySize _ = KeySizeFixed 16
16    cipherInit key  = Twofish128 <$> (initTwofish =<< validateKeySize (undefined :: Twofish128) key)
17
18instance BlockCipher Twofish128 where
19    blockSize                 _ = 16
20    ecbEncrypt (Twofish128 key) = encrypt key
21    ecbDecrypt (Twofish128 key) = decrypt key
22
23newtype Twofish192 = Twofish192 Twofish
24
25instance Cipher Twofish192 where
26    cipherName    _ = "Twofish192"
27    cipherKeySize _ = KeySizeFixed 24
28    cipherInit key  = Twofish192 <$> (initTwofish =<< validateKeySize (undefined :: Twofish192) key)
29
30instance BlockCipher Twofish192 where
31    blockSize                 _ = 16
32    ecbEncrypt (Twofish192 key) = encrypt key
33    ecbDecrypt (Twofish192 key) = decrypt key
34
35newtype Twofish256 = Twofish256 Twofish
36
37instance Cipher Twofish256 where
38    cipherName    _ = "Twofish256"
39    cipherKeySize _ = KeySizeFixed 32
40    cipherInit key  = Twofish256 <$> (initTwofish =<< validateKeySize (undefined :: Twofish256) key)
41
42instance BlockCipher Twofish256 where
43    blockSize                 _ = 16
44    ecbEncrypt (Twofish256 key) = encrypt key
45    ecbDecrypt (Twofish256 key) = decrypt key
46