Parameters for OAEP encryption/decryption
Constructors
OAEPParamsoaepHash :: hashHash function to use.
oaepMaskGenAlg :: MaskGenAlgorithm seed outputMask Gen algorithm to use.
oaepLabel :: Maybe ByteStringOptional label prepended to message.
:: a typeCtrl KGHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11
Modulecrypton-2.1.7Haskell2010
Parameters for OAEP encryption/decryption
OAEPParamsoaepHash :: hashHash function to use.
oaepMaskGenAlg :: MaskGenAlgorithm seed outputMask Gen algorithm to use.
oaepLabel :: Maybe ByteStringOptional label prepended to message.
Default Params with a specified hash function
encryptWithSeed :: HashAlgorithm hash=> ByteStringSeed
-> OAEPParams hash ByteString ByteStringOAEP params to use for encryption
-> PublicKeyPublic key.
-> ByteStringMessage to encrypt
-> Either Error ByteStringEncrypt a message using OAEP with a predefined seed.
encrypt :: (HashAlgorithm hash, MonadRandom m)=> OAEPParams hash ByteString ByteStringOAEP params to use for encryption.
-> PublicKeyPublic key.
-> ByteStringMessage to encrypt
-> m (Either Error ByteString)Encrypt a message using OAEP
decrypt :: HashAlgorithm hash=> Maybe BlinderOptional blinder
-> OAEPParams hash ByteString ByteStringOAEP params to use for decryption
-> PrivateKeyPrivate key
-> ByteStringCipher text
-> Either Error ByteStringDecrypt 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 :: (HashAlgorithm hash, MonadRandom m)=> OAEPParams hash ByteString ByteStringOAEP params to use for decryption
-> PrivateKeyPrivate key
-> ByteStringCipher text
-> m (Either Error ByteString)Decrypt a ciphertext using OAEP and by automatically generating a blinder.