module Codec.Encryption.Ciphers where
import Foreign.C.Types
class CipherType a where
cipherTypeToC :: a -> CInt
class CipherMode a where
cipherModeToC :: a -> CInt
data CipherIDEA = CipherIDEA deriving Show
data Cipher3DES = Cipher3DES deriving Show
data CipherCast5 = CipherCast5 deriving Show
data CipherBlowfish = CipherBlowfish deriving Show
data CipherAES = CipherAES deriving Show
data CipherAES128 = CipherAES128 deriving Show
data CipherAES192 = CipherAES192 deriving Show
data CipherAES256 = CipherAES256 deriving Show
data CipherRIJNDAEL = CipherRIJDNDAEL deriving Show
data CipherRIJNDAEL128 = CipherRIJNDAEL128 deriving Show
data CipherRIJNDAEL192 = CipherRIJNDAEL192 deriving Show
data CipherRIJNDAEL256 = CipherRIJNDAEL256 deriving Show
data CipherTwofish = CipherTwofish deriving Show
data CipherTwofish128 = CipherTwofish128 deriving Show
data CipherArcfour = CipherArcfour deriving Show
data CipherDES = CipherDES deriving Show
instance CipherType CipherIDEA where cipherTypeToC _ = 1
instance CipherType Cipher3DES where cipherTypeToC _ = 2
instance CipherType CipherCast5 where cipherTypeToC _ = 3
instance CipherType CipherBlowfish where cipherTypeToC _ = 4
instance CipherType CipherAES where cipherTypeToC _ = 7
instance CipherType CipherAES128 where cipherTypeToC _ = 7
instance CipherType CipherAES192 where cipherTypeToC _ = 8
instance CipherType CipherAES256 where cipherTypeToC _ = 9
instance CipherType CipherRIJNDAEL where cipherTypeToC _ = 7
instance CipherType CipherRIJNDAEL128 where cipherTypeToC _ = 7
instance CipherType CipherRIJNDAEL192 where cipherTypeToC _ = 8
instance CipherType CipherRIJNDAEL256 where cipherTypeToC _ = 9
instance CipherType CipherTwofish where cipherTypeToC _ = 10
instance CipherType CipherTwofish128 where cipherTypeToC _ = 303
instance CipherType CipherArcfour where cipherTypeToC _ = 301
instance CipherType CipherDES where cipherTypeToC _ = 302
data ModeNone = ModeNone deriving Show
data ModeECB = ModeECB deriving Show
data ModeCFB = ModeCFB deriving Show
data ModeCBC = ModeCBC deriving Show
data ModeStream = ModeStream deriving Show
data ModeOFB = ModeOFB deriving Show
data ModeCTR = ModeCTR deriving Show
instance CipherMode ModeNone where cipherModeToC _ = 0
instance CipherMode ModeECB where cipherModeToC _ = 1
instance CipherMode ModeCFB where cipherModeToC _ = 2
instance CipherMode ModeCBC where cipherModeToC _ = 3
instance CipherMode ModeStream where cipherModeToC _ = 4
instance CipherMode ModeOFB where cipherModeToC _ = 5
instance CipherMode ModeCTR where cipherModeToC _ = 6
data CipherFlag
= Secure
| EnableSync
| CBC_CTS
| CBC_MAC
deriving (Show,Eq)
flagToC :: CipherFlag -> CUInt
flagToC Secure = 1
flagToC EnableSync = 2
flagToC CBC_CTS = 4
flagToC CBC_MAC = 8