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

Crypto.PubKey.RSA.PSS

Description

 
Synopsis

Documentation

data PSSParams hash seed output Source #

Parameters for PSS signature/verification.

Constructors

PSSParams 

Fields

defaultPSSParams :: (ByteArrayAccess seed, ByteArray output, HashAlgorithm hash) => hash -> PSSParams hash seed output Source #

Default Params with a specified hash function

defaultPSSParamsSHA1 :: PSSParams SHA1 ByteString ByteString Source #

Default Params using SHA1 algorithm.

Sign and verify functions

signWithSalt Source #

Arguments

:: HashAlgorithm hash 
=> ByteString

Salt to use

-> Maybe Blinder

optional blinder to use

-> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

RSA Private Key

-> ByteString

Message to sign

-> Either Error ByteString 

Sign using the PSS parameters and the salt explicitely passed as parameters.

the function ignore SaltLength from the PSS Parameters

See Blinder for what the optional blinder covers and when leaving it out is a decision rather than a default. signSafer generates one for you.

signDigestWithSalt Source #

Arguments

:: HashAlgorithm hash 
=> ByteString

Salt to use

-> Maybe Blinder

optional blinder to use

-> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

RSA Private Key

-> Digest hash

Message digest

-> Either Error ByteString 

Sign using the PSS parameters and the salt explicitely passed as parameters.

the function ignore SaltLength from the PSS Parameters

See Blinder for what the optional blinder covers and when leaving it out is a decision rather than a default. signSafer generates one for you.

sign Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> Maybe Blinder

optional blinder to use

-> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

RSA Private Key

-> ByteString

Message to sign

-> m (Either Error ByteString) 

Sign using the PSS Parameters

See Blinder for what the optional blinder covers and when leaving it out is a decision rather than a default. signSafer generates one for you.

signDigest Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> Maybe Blinder

optional blinder to use

-> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

RSA Private Key

-> Digest hash

Message digest

-> m (Either Error ByteString) 

Sign using the PSS Parameters

See Blinder for what the optional blinder covers and when leaving it out is a decision rather than a default. signSafer generates one for you.

signSafer Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

private key

-> ByteString

message to sign

-> m (Either Error ByteString) 

Sign using the PSS Parameters, blinded with the pair kept for this key; see Crypto.PubKey.RSA.Blinded.

signDigestSafer Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> PSSParams hash ByteString ByteString

PSS Parameters to use

-> PrivateKey

private key

-> Digest hash

message digst

-> m (Either Error ByteString) 

Sign using the PSS Parameters, blinded with the pair kept for this key; see Crypto.PubKey.RSA.Blinded.

signBlinded Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> PSSParams hash ByteString ByteString 
-> BlindedKey 
-> ByteString

message to sign

-> m (Either Error ByteString, BlindedKey) 

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

signDigestBlinded Source #

Arguments

:: (HashAlgorithm hash, MonadRandom m) 
=> PSSParams hash ByteString ByteString 
-> BlindedKey 
-> Digest hash

message digest

-> m (Either Error ByteString, BlindedKey) 

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

verify Source #

Arguments

:: HashAlgorithm hash 
=> PSSParams hash ByteString ByteString

PSS Parameters to use to verify, this need to be identical to the parameters when signing

-> PublicKey

RSA Public Key

-> ByteString

Message to verify

-> ByteString

Signature

-> Bool 

Verify a signature using the PSS Parameters

verifyDigest Source #

Arguments

:: HashAlgorithm hash 
=> PSSParams hash ByteString ByteString

PSS Parameters to use to verify, this need to be identical to the parameters when signing

-> PublicKey

RSA Public Key

-> Digest hash

Digest to verify

-> ByteString

Signature

-> Bool 

Verify a signature using the PSS Parameters

Following RFC 8017, the signature is rejected unless it is exactly as long as the modulus (section 8.1.2, step 1) and its integer representative is below the modulus (RSAVP1, section 5.2.2, step 1). The public-key operation normalises any multiple of the modulus away, so without the second check s + n would verify as readily as s, and a third party could turn one valid signature into another without the private key.