crypto-pubkey-0.2.4: Public Key cryptography

Portability | Good
Stability | experimental
Maintainer | Vincent Hanquez <vincent@snarc.org>
Safe Haskell | None

Crypto.PubKey.DH

Description

Synopsis

- data Params = Params {
  - params_p :: Integer
  - params_g :: Integer
  }
- data PublicNumber
- data PrivateNumber
- data SharedKey
- generateParams :: CPRG g => g -> Int -> Integer -> (Params, g)
- generatePrivate :: CPRG g => g -> Params -> (PrivateNumber, g)
- calculatePublic :: Params -> PrivateNumber -> PublicNumber
- generatePublic :: Params -> PrivateNumber -> PublicNumber
- getShared :: Params -> PrivateNumber -> PublicNumber -> SharedKey

# Documentation

data Params

Represent Diffie Hellman parameters namely P (prime), and G (generator).

Constructors

Params |

Fields

params_p :: Integer
params_g :: Integer

Instances

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

data PublicNumber

Represent Diffie Hellman public number Y.

Instances

Enum PublicNumber |
Eq PublicNumber |
Num PublicNumber |
Ord PublicNumber |
Read PublicNumber |
Real PublicNumber |
Show PublicNumber |

data PrivateNumber

Represent Diffie Hellman private number X.

Instances

Enum PrivateNumber |
Eq PrivateNumber |
Num PrivateNumber |
Ord PrivateNumber |
Read PrivateNumber |
Real PrivateNumber |
Show PrivateNumber |

data SharedKey

Represent Diffie Hellman shared secret.

Instances

Enum SharedKey |
Eq SharedKey |
Num SharedKey |
Ord SharedKey |
Read SharedKey |
Real SharedKey |
Show SharedKey |

generateParams :: CPRG g => g -> Int -> Integer -> (Params, g)Source

generate params from a specific generator (2 or 5 are common values) we generate a safe prime (a prime number of the form 2p+1 where p is also prime)

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

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

calculatePublic :: Params -> PrivateNumber -> PublicNumber Source

calculate the public number from the parameters and the private key this number is usually called Y in DH text.

generatePublic :: Params -> PrivateNumber -> PublicNumber Source

calculate the public number from the parameters and the private key this number is usually called Y in DH text.

DEPRECATED use calculatePublic

getShared :: Params -> PrivateNumber -> PublicNumber -> SharedKey Source

generate a shared key using our private number and the other party public number