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.OAEP

Contents

- OAEP encryption
- OAEP decryption

Description

RSA OAEP mode http://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding

Synopsis

- data OAEPParams = OAEPParams {
  - oaepHash :: HashFunction
  - oaepMaskGenAlg :: MaskGenAlgorithm
  - oaepLabel :: Maybe ByteString
  }
- defaultOAEPParams :: HashFunction -> OAEPParams
- encryptWithSeed :: ByteString -> OAEPParams -> PublicKey -> ByteString -> Either Error ByteString
- encrypt :: CPRG g => g -> OAEPParams -> PublicKey -> ByteString -> (Either Error ByteString, g)
- decrypt :: Maybe Blinder -> OAEPParams -> PrivateKey -> ByteString -> Either Error ByteString
- decryptSafer :: CPRG g => g -> OAEPParams -> PrivateKey -> ByteString -> (Either Error ByteString, g)

# Documentation

data OAEPParams #

Parameters for OAEP encryption/decryption

Constructors

OAEPParams |
Fields oaepHash :: HashFunction Hash function to use. oaepMaskGenAlg :: MaskGenAlgorithm Mask Gen algorithm to use. oaepLabel :: Maybe ByteString Optional label prepended to message.

defaultOAEPParams :: HashFunction -> OAEPParams #

Default Params with a specified hash function

# OAEP encryption

encryptWithSeed #

Arguments

:: ByteString | Seed
-> OAEPParams | OAEP params to use for encryption
-> PublicKey | Public key.
-> ByteString | Message to encrypt
-> Either Error ByteString |

Encrypt a message using OAEP with a predefined seed.

encrypt #

Arguments

:: CPRG g |
=> g | random number generator.
-> OAEPParams | OAEP params to use for encryption.
-> PublicKey | Public key.
-> ByteString | Message to encrypt
-> (Either Error ByteString, g) |

Encrypt a message using OAEP

# OAEP decryption

decrypt #

Arguments

:: Maybe Blinder | Optional blinder
-> OAEPParams | OAEP params to use for decryption
-> PrivateKey | Private key
-> ByteString | Cipher text
-> Either Error ByteString |

Decrypt a ciphertext using OAEP

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 decryptSafer

decryptSafer #

Arguments

:: CPRG g |
=> g | random number generator
-> OAEPParams | OAEP params to use for decryption
-> PrivateKey | Private key
-> ByteString | Cipher text
-> (Either Error ByteString, g) |

Decrypt a ciphertext using OAEP and by automatically generating a blinder.