crypto-pubkey-0.2.4: Public Key cryptography

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

Crypto.PubKey.DSA

Contents

Description

An implementation of the Digital Signature Algorithm (DSA)

Synopsis

Documentation

data Params

Represent DSA parameters namely P, G, and Q.

Constructors

Params 

Fields

params_p :: Integer

DSA p

params_g :: Integer

DSA g

params_q :: Integer

DSA q

data Signature

Represent a DSA signature namely R and S.

Constructors

Signature 

Fields

sign_r :: Integer

DSA r

sign_s :: Integer

DSA s

data PublicKey

Represent a DSA public key.

Constructors

PublicKey 

Fields

public_params :: Params

DSA parameters

public_y :: PublicNumber

DSA public Y

data PrivateKey

Represent a DSA private key.

Only x need to be secret. the DSA parameters are publicly shared with the other side.

Constructors

PrivateKey 

Fields

private_params :: Params

DSA parameters

private_x :: PrivateNumber

DSA private X

generation

generatePrivate :: CPRG g => g -> Params -> (PrivateNumber, g)Source

generate a private number with no specific property this number is usually called X in DSA text.

calculatePublic :: Params -> PrivateNumber -> PublicNumberSource

Calculate the public number from the parameters and the private key

signature primitive

sign :: CPRG g => g -> PrivateKey -> HashFunction -> ByteString -> (Signature, g)Source

sign message using the private key.

signWithSource

Arguments

:: Integer

k random number

-> PrivateKey

private key

-> HashFunction

hash function

-> ByteString

message to sign

-> Maybe Signature 

sign message using the private key and an explicit k number.

verification primitive

verify :: HashFunction -> PublicKey -> Signature -> ByteString -> BoolSource

verify a bytestring using the public key.