crypto-pubkey-0.2.8: Public Key cryptography

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | Good
Safe Haskell | None
Language | Haskell98

Crypto.PubKey.RSA.PKCS15

Contents

- padding and unpadding
- private key operations
- public key operations

Description

Synopsis

- pad :: CPRG g => g -> Int -> ByteString -> Either Error (ByteString, g)
- padSignature :: Int -> ByteString -> Either Error ByteString
- unpad :: ByteString -> Either Error ByteString
- decrypt :: Maybe Blinder -> PrivateKey -> ByteString -> Either Error ByteString
- decryptSafer :: CPRG g => g -> PrivateKey -> ByteString -> (Either Error ByteString, g)
- sign :: Maybe Blinder -> HashDescr -> PrivateKey -> ByteString -> Either Error ByteString
- signSafer :: CPRG g => g -> HashDescr -> PrivateKey -> ByteString -> (Either Error ByteString, g)
- encrypt :: CPRG g => g -> PublicKey -> ByteString -> (Either Error ByteString, g)
- verify :: HashDescr -> PublicKey -> ByteString -> ByteString -> Bool

# padding and unpadding

pad :: CPRG g => g -> Int -> ByteString -> Either Error (ByteString, g) #

This produce a standard PKCS1.5 padding for encryption

padSignature :: Int -> ByteString -> Either Error ByteString #

Produce a standard PKCS1.5 padding for signature

unpad :: ByteString -> Either Error ByteString #

Try to remove a standard PKCS1.5 encryption padding.

# private key operations

decrypt #

Arguments

:: Maybe Blinder | optional blinder
-> PrivateKey | RSA private key
-> ByteString | cipher text
-> Either Error ByteString |

decrypt message using the private key.

When the decryption is not in a context where an attacker could gain information from the timing of the operation, the blinder can be set to None.

If unsure always set a blinder or use decryptSafer

decryptSafer #

Arguments

:: CPRG g |
=> g | random generator
-> PrivateKey | RSA private key
-> ByteString | cipher text
-> (Either Error ByteString, g) |

decrypt message using the private key and by automatically generating a blinder.

sign #

Arguments

:: Maybe Blinder | optional blinder
-> HashDescr | hash descriptor
-> PrivateKey | private key
-> ByteString | message to sign
-> Either Error ByteString |

sign message using private key, a hash and its ASN1 description

When the signature is not in a context where an attacker could gain information from the timing of the operation, the blinder can be set to None.

If unsure always set a blinder or use signSafer

signSafer #

Arguments

:: CPRG g |
=> g | random generator
-> HashDescr | Hash descriptor
-> PrivateKey | private key
-> ByteString | message to sign
-> (Either Error ByteString, g) |

sign message using the private key and by automatically generating a blinder.

# public key operations

encrypt :: CPRG g => g -> PublicKey -> ByteString -> (Either Error ByteString, g) #

encrypt a bytestring using the public key and a CPRG random generator.

the message need to be smaller than the key size - 11

verify :: HashDescr -> PublicKey -> ByteString -> ByteString -> Bool #

verify message with the signed message