cryptonite-0.30: Cryptography Primitives sink

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

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 hash seed output = OAEPParams {
  - oaepHash :: hash
  - oaepMaskGenAlg :: MaskGenAlgorithm seed output
  - oaepLabel :: Maybe ByteString
  }
- defaultOAEPParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash) => hash -> OAEPParams hash seed output
- encryptWithSeed :: HashAlgorithm hash => ByteString -> OAEPParams hash ByteString ByteString -> PublicKey -> ByteString -> Either Error ByteString
- encrypt :: (HashAlgorithm hash, MonadRandom m) => OAEPParams hash ByteString ByteString -> PublicKey -> ByteString -> m (Either Error ByteString)
- decrypt :: HashAlgorithm hash => Maybe Blinder -> OAEPParams hash ByteString ByteString -> PrivateKey -> ByteString -> Either Error ByteString
- decryptSafer :: (HashAlgorithm hash, MonadRandom m) => OAEPParams hash ByteString ByteString -> PrivateKey -> ByteString -> m (Either Error ByteString)

# Documentation

data OAEPParams hash seed output Source #

Parameters for OAEP encryption/decryption

Constructors

OAEPParams |

Fields

- oaepHash :: hash

  Hash function to use.

- oaepMaskGenAlg :: MaskGenAlgorithm seed output

  Mask Gen algorithm to use.

- oaepLabel :: Maybe ByteString

  Optional label prepended to message.

defaultOAEPParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash) => hash -> OAEPParams hash seed output Source #

Default Params with a specified hash function

# OAEP encryption

encryptWithSeed Source #

Arguments

:: HashAlgorithm hash |
=> ByteString | Seed
-> OAEPParams hash ByteString ByteString | 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 Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) |
=> OAEPParams hash ByteString ByteString | OAEP params to use for encryption.
-> PublicKey | Public key.
-> ByteString | Message to encrypt
-> m (Either Error ByteString) |

Encrypt a message using OAEP

# OAEP decryption

decrypt Source #

Arguments

:: HashAlgorithm hash |
=> Maybe Blinder | Optional blinder
-> OAEPParams hash ByteString ByteString | 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 Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) |
=> OAEPParams hash ByteString ByteString | OAEP params to use for decryption
-> PrivateKey | Private key
-> ByteString | Cipher text
-> m (Either Error ByteString) |

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