crypto-pubkey-0.2.1: Public Key cryptography

PortabilityGood
Stabilityexperimental
MaintainerVincent Hanquez <vincent@snarc.org>
Safe HaskellNone

Crypto.PubKey.RSA.PKCS15

Contents

Description

 

Synopsis

padding and unpadding

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

This produce a standard PKCS1.5 padding for encryption

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

Produce a standard PKCS1.5 padding for signature

unpad :: ByteString -> Either Error ByteStringSource

Try to remove a standard PKCS1.5 encryption padding.

private key operations

decryptSource

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

decryptSaferSource

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.

signSource

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

signSaferSource

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)Source

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 -> BoolSource

verify message with the signed message