crypto-pubkey-0.2.8: Public Key cryptography

LicenseBSD-style
MaintainerVincent Hanquez <vincent@snarc.org>
Stabilityexperimental
PortabilityGood
Safe HaskellNone
LanguageHaskell98

Crypto.PubKey.RSA.PKCS15

Contents

Description

 

Synopsis

padding and unpadding

pad :: CPRG g => g -> Int -> ByteString -> Either Error (ByteString, g)

This produce a standard PKCS1.5 padding for encryption

padSignature :: Int -> ByteString -> Either Error ByteString

Produce a standard PKCS1.5 padding for signature

unpad :: ByteString -> Either Error ByteString

Try to remove a standard PKCS1.5 encryption padding.

private key operations

decrypt

Arguments

:: Maybe Blinder

optional blinder

-> PrivateKey

RSA private key

-> ByteString

cipher text

-> Either Error ByteString 

decrypt message using the private key.

When the decryption 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

Arguments

:: CPRG g 
=> g

random generator

-> PrivateKey

RSA private key

-> ByteString

cipher text

-> (Either Error ByteString, g) 

decrypt message using the private key and by automatically generating a blinder.

sign

Arguments

:: Maybe Blinder

optional blinder

-> HashDescr

hash descriptor

-> PrivateKey

private key

-> ByteString

message to sign

-> Either Error ByteString 

sign message using private key, a hash and its ASN1 description

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 signSafer

signSafer

Arguments

:: CPRG g 
=> g

random generator

-> HashDescr

Hash descriptor

-> PrivateKey

private key

-> ByteString

message to sign

-> (Either Error ByteString, g) 

sign message using the private key and by automatically generating a blinder.

public key operations

encrypt :: CPRG g => g -> PublicKey -> ByteString -> (Either Error ByteString, g)

encrypt a bytestring using the public key and a CPRG random generator.

the message need to be smaller than the key size - 11

verify :: HashDescr -> PublicKey -> ByteString -> ByteString -> Bool

verify message with the signed message