cryptocipher-0.2: Symmetrical Block and Stream CiphersContentsIndex
Crypto.Cipher.RSA
PortabilityGood
Stabilityexperimental
MaintainerVincent Hanquez <vincent@snarc.org>
Description
Synopsis
data Error
= MessageSizeIncorrect
| MessageTooLong
| MessageNotRecognized
| RandomGenFailure GenError
| KeyInternalError
data PublicKey = PublicKey {
public_sz :: Int
public_n :: Integer
public_e :: Integer
}
data PrivateKey = PrivateKey {
private_sz :: Int
private_n :: Integer
private_d :: Integer
private_p :: Integer
private_q :: Integer
private_dP :: Integer
private_dQ :: Integer
private_qinv :: Integer
}
decrypt :: PrivateKey -> ByteString -> Either Error ByteString
encrypt :: CryptoRandomGen g => g -> PublicKey -> ByteString -> Either Error (ByteString, g)
Documentation
data Error
Constructors
MessageSizeIncorrectthe message to decrypt is not of the correct size (need to be == private_size)
MessageTooLongthe message to encrypt is too long (>= private_size - 11)
MessageNotRecognizedthe message decrypted doesn't have a PKCS15 structure (0 2 .. 0 msg)
RandomGenFailure GenErrorthe random generator returns an error. give the opportunity to reseed for example.
KeyInternalErrorthe whole key is probably not valid, since the message is bigger than the key size
show/hide Instances
data PublicKey
Constructors
PublicKey
public_sz :: Intsize of key in bytes
public_n :: Integerpublic p*q
public_e :: Integerpublic exponant e
show/hide Instances
data PrivateKey
Constructors
PrivateKey
private_sz :: Intsize of key in bytes
private_n :: Integerprivate p*q
private_d :: Integerprivate exponant d
private_p :: Integerp prime number
private_q :: Integerq prime number
private_dP :: Integerd mod (p-1)
private_dQ :: Integerd mod (q-1)
private_qinv :: Integerq^(-1) mod p
show/hide Instances
decrypt :: PrivateKey -> ByteString -> Either Error ByteString
decrypt message using the private key.
encrypt :: CryptoRandomGen g => g -> PublicKey -> ByteString -> Either Error (ByteString, g)
encrypt a bytestring using the public key and a CryptoRandomGen random generator. - the message need to be smaller than the key size - 11
Produced by Haddock version 2.7.2