crypto-pubkey-0.2.8: Public Key cryptography

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | Good
Safe Haskell | None
Language | Haskell98

Crypto.PubKey.DSA

Contents

- generation
- signature primitive
- verification primitive

Description

An implementation of the Digital Signature Algorithm (DSA)

Synopsis

- data Params :: * = Params {
  - params_p :: Integer
  - params_g :: Integer
  - params_q :: Integer
  }
- data Signature :: * = Signature {
  - sign_r :: Integer
  - sign_s :: Integer
  }
- data PublicKey :: * = PublicKey {
  - public_params :: Params
  - public_y :: PublicNumber
  }
- data PrivateKey :: * = PrivateKey {
  - private_params :: Params
  - private_x :: PrivateNumber
  }
- generatePrivate :: CPRG g => g -> Params -> (PrivateNumber, g)
- calculatePublic :: Params -> PrivateNumber -> PublicNumber
- sign :: CPRG g => g -> PrivateKey -> HashFunction -> ByteString -> (Signature, g)
- signWith :: Integer -> PrivateKey -> HashFunction -> ByteString -> Maybe Signature
- verify :: HashFunction -> PublicKey -> Signature -> ByteString -> Bool

# 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

Instances

Eq Params |
Data Params |
Read Params |
Show Params |
ASN1Object Params |

data Signature :: *

Represent a DSA signature namely R and S.

Constructors

Signature |

Fields

sign_r :: Integer

  DSA r

sign_s :: Integer

  DSA s

Instances

Eq Signature |
Data Signature |
Read Signature |
Show Signature |
ASN1Object Signature |

data PublicKey :: *

Represent a DSA public key.

Constructors

PublicKey |

Fields

public_params :: Params

  DSA parameters

public_y :: PublicNumber

  DSA public Y

Instances

Eq PublicKey |
Data PublicKey |
Read PublicKey |
Show PublicKey |
ASN1Object PublicKey |

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

Instances

Eq PrivateKey |
Data PrivateKey |
Read PrivateKey |
Show PrivateKey |

# 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 -> PublicNumber Source

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.

signWith Source

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

verify a bytestring using the public key.