| License | BSD-style |
|---|---|
| Maintainer | Vincent Hanquez <vincent@snarc.org> |
| Stability | experimental |
| Portability | Good |
| Safe Haskell | None |
| Language | Haskell2010 |
Crypto.PubKey.RSA.OAEP
Contents
Description
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)
- decryptBlinded :: (HashAlgorithm hash, MonadRandom m) => OAEPParams hash ByteString ByteString -> BlindedKey -> ByteString -> m (Either Error ByteString, BlindedKey)
Documentation
data OAEPParams hash seed output Source #
Parameters for OAEP encryption/decryption
Constructors
| OAEPParams | |
Fields
| |
defaultOAEPParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash) => hash -> OAEPParams hash seed output Source #
Default Params with a specified hash function
OAEP encryption
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.
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
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
The blinder is optional and Nothing is accepted, but see Blinder for
what it covers and when leaving it out is a decision rather than a default.
decryptSafer generates one for you.
Following RFC 8017, the ciphertext is rejected unless it is exactly as long
as the modulus (section 7.1.2, step 1) and its integer representative is
below the modulus (RSADP, section 5.1.2, step 1). The decryption primitive
normalises any multiple of the modulus away, so without the second check
c + n would decrypt to the same message as c, and a ciphertext would not
be unique to its plaintext. Both checks are made on the ciphertext alone,
which is public, and report MessageSizeIncorrect.
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, blinded with the pair kept for this key; see Crypto.PubKey.RSA.Blinded.
Arguments
| :: (HashAlgorithm hash, MonadRandom m) | |
| => OAEPParams hash ByteString ByteString | |
| -> BlindedKey | |
| -> ByteString | Cipher text |
| -> m (Either Error ByteString, BlindedKey) |
decrypt with the blinding a BlindedKey keeps, and the key for the
next operation.