crypton-2.2.5: Cryptography Primitives
LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell2010

Crypto.PubKey.RSA.OAEP

Description

Synopsis

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

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

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.

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, blinded with the pair kept for this key; see Crypto.PubKey.RSA.Blinded.

decryptBlinded Source #

decrypt with the blinding a BlindedKey keeps, and the key for the next operation.