-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Symmetrical Block, Stream and PubKey Ciphers -- -- Symmetrical Block, Stream and PubKey Ciphers @package cryptocipher @version 0.2.8 module Crypto.Cipher.DSA data Error -- | signature is not valid r or s is not between the bound 0..q InvalidSignature :: Error -- | the random generator returns an error. give the opportunity to reseed -- for example. RandomGenFailure :: GenError -> Error type Params = (Integer, Integer, Integer) type Signature = (Integer, Integer) data PublicKey PublicKey :: Params -> Integer -> PublicKey public_params :: PublicKey -> Params public_y :: PublicKey -> Integer data PrivateKey PrivateKey :: Params -> Integer -> PrivateKey private_params :: PrivateKey -> Params private_x :: PrivateKey -> Integer -- | sign message using the private key. sign :: CryptoRandomGen g => g -> (ByteString -> ByteString) -> PrivateKey -> ByteString -> Either GenError (Signature, g) -- | verify a bytestring using the public key. verify :: Signature -> (ByteString -> ByteString) -> PublicKey -> ByteString -> Either Error Bool instance Show Error instance Eq Error instance Show PublicKey instance Show PrivateKey module Crypto.Cipher.RSA data Error -- | the message to decrypt is not of the correct size (need to be == -- private_size) MessageSizeIncorrect :: Error -- | the message to encrypt is too long (>= private_size - 11) MessageTooLong :: Error -- | the message decrypted doesn't have a PKCS15 structure (0 2 .. 0 msg) MessageNotRecognized :: Error -- | the signature generated through the hash is too long to process with -- this key SignatureTooLong :: Error -- | the random generator returns an error. give the opportunity to reseed -- for example. RandomGenFailure :: GenError -> Error -- | the whole key is probably not valid, since the message is bigger than -- the key size KeyInternalError :: Error data PublicKey PublicKey :: Int -> Integer -> Integer -> PublicKey -- | size of key in bytes public_sz :: PublicKey -> Int -- | public p*q public_n :: PublicKey -> Integer -- | public exponant e public_e :: PublicKey -> Integer data PrivateKey PrivateKey :: Int -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> Integer -> PrivateKey -- | size of key in bytes private_sz :: PrivateKey -> Int -- | private p*q private_n :: PrivateKey -> Integer -- | private exponant d private_d :: PrivateKey -> Integer -- | p prime number private_p :: PrivateKey -> Integer -- | q prime number private_q :: PrivateKey -> Integer -- | d mod (p-1) private_dP :: PrivateKey -> Integer -- | d mod (q-1) private_dQ :: PrivateKey -> Integer -- | q^(-1) mod p private_qinv :: PrivateKey -> Integer type HashF = ByteString -> ByteString type HashASN1 = ByteString -- | decrypt message using the private key. decrypt :: PrivateKey -> ByteString -> Either Error ByteString -- | encrypt a bytestring using the public key and a CryptoRandomGen random -- generator. - the message need to be smaller than the key size - 11 encrypt :: CryptoRandomGen g => g -> PublicKey -> ByteString -> Either Error (ByteString, g) -- | sign message using private key, a hash and its ASN1 description sign :: HashF -> HashASN1 -> PrivateKey -> ByteString -> Either Error ByteString -- | verify message with the signed message verify :: HashF -> HashASN1 -> PublicKey -> ByteString -> ByteString -> Either Error Bool instance Show Error instance Eq Error instance Show PublicKey instance Show PrivateKey -- | this only cover Camellia 128 bits for now, API will change once 192 -- and 256 mode are implemented too module Crypto.Cipher.Camellia data Key Key :: Vector Word64 -> Vector Word64 -> Vector Word64 -> Key k :: Key -> Vector Word64 kw :: Key -> Vector Word64 ke :: Key -> Vector Word64 initKey :: ByteString -> Either String Key -- | encrypt with the key a bytestring and returns the encrypted bytestring encrypt :: Key -> ByteString -> ByteString -- | decrypt with the key a bytestring and returns the encrypted bytestring decrypt :: Key -> ByteString -> ByteString instance Show Word128 instance Eq Word128 instance Show Key module Crypto.Cipher.AES data Key type IV = ByteString -- | encrypt using simple EBC mode encrypt :: Key -> ByteString -> ByteString -- | decrypt using simple EBC mode decrypt :: Key -> ByteString -> ByteString -- | encrypt using CBC mode - IV need to be 16 bytes and the data to -- encrypt a multiple of 16 bytes encryptCBC :: Key -> IV -> ByteString -> ByteString -- | decrypt using CBC mode - IV need to be 16 bytes and the data to -- decrypt a multiple of 16 bytes decryptCBC :: Key -> IV -> ByteString -> ByteString initKey128 :: ByteString -> Either String Key initKey192 :: ByteString -> Either String Key initKey256 :: ByteString -> Either String Key data AES128 data AES192 data AES256 instance Show Key instance Eq Key instance Serialize AES256 instance Serialize AES192 instance Serialize AES128 instance BlockCipher AES256 instance BlockCipher AES192 instance BlockCipher AES128 module Crypto.Cipher.RC4 type Ctx = (Vector Word8, Word8, Word8) -- | initCtx initialize the Ctx with the key as parameter. the key can be -- of any size but not empty initCtx :: [Word8] -> Ctx -- | encrypt with the current context a bytestring and returns a new -- context and the resulted encrypted bytestring encrypt :: Ctx -> ByteString -> (Ctx, ByteString) -- | decrypt with the current context a bytestring and returns a new -- context and the resulted decrypted bytestring decrypt :: Ctx -> ByteString -> (Ctx, ByteString) -- | encrypt with the current context a lazy bytestring and returns a new -- context and the resulted lencrypted lazy bytestring encryptlazy :: Ctx -> ByteString -> (Ctx, ByteString) -- | decrypt with the current context a lazy bytestring and returns a new -- context and the resulted decrypted lazy bytestring decryptlazy :: Ctx -> ByteString -> (Ctx, ByteString)