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

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

Constructors

Params |

Fields

- params_p :: Integer
- params_g :: Integer

Instances

Eq Params |
Instance details Defined in Crypto.Types.PubKey.DH Methods (==) :: Params -> Params -> Bool Source # (/=) :: Params -> Params -> Bool Source #
Data Params |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Params -> c Params Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Params Source #

toConstr :: Params -> Constr Source #

dataTypeOf :: Params -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Params) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Params) Source #

gmapT :: (forall b. Data b => b -> b) -> Params -> Params Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Params -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Params -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Params -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Params -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Params -> m Params Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Params -> m Params Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Params -> m Params Source #

Read Params |
Instance details Defined in Crypto.Types.PubKey.DH Methods readsPrec :: Int -> ReadS Params Source # readList :: ReadS [Params] Source # readPrec :: ReadPrec Params Source # readListPrec :: ReadPrec [Params] Source #
Show Params |
Instance details Defined in Crypto.Types.PubKey.DH Methods showsPrec :: Int -> Params -> ShowS Source # show :: Params -> String Source # showList :: [Params] -> ShowS Source #
ASN1Object Params |
Instance details Defined in Crypto.Types.PubKey.DH Methods toASN1 :: Params -> ASN1S fromASN1 :: [ASN1] -> Either String (Params, [ASN1])

data PublicNumber Source #

Represent Diffie Hellman public number Y.

Instances

Enum PublicNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

succ :: PublicNumber -> PublicNumber Source #

pred :: PublicNumber -> PublicNumber Source #

toEnum :: Int -> PublicNumber Source #

fromEnum :: PublicNumber -> Int Source #

enumFrom :: PublicNumber -> [PublicNumber] Source #

enumFromThen :: PublicNumber -> PublicNumber -> [PublicNumber] Source #

enumFromTo :: PublicNumber -> PublicNumber -> [PublicNumber] Source #

enumFromThenTo :: PublicNumber -> PublicNumber -> PublicNumber -> [PublicNumber] Source #

Eq PublicNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods (==) :: PublicNumber -> PublicNumber -> Bool Source # (/=) :: PublicNumber -> PublicNumber -> Bool Source #
Num PublicNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

(+) :: PublicNumber -> PublicNumber -> PublicNumber Source #

(-) :: PublicNumber -> PublicNumber -> PublicNumber Source #

(*) :: PublicNumber -> PublicNumber -> PublicNumber Source #

negate :: PublicNumber -> PublicNumber Source #

abs :: PublicNumber -> PublicNumber Source #

signum :: PublicNumber -> PublicNumber Source #

fromInteger :: Integer -> PublicNumber Source #

Ord PublicNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

compare :: PublicNumber -> PublicNumber -> Ordering Source #

(<) :: PublicNumber -> PublicNumber -> Bool Source #

(<=) :: PublicNumber -> PublicNumber -> Bool Source #

(>) :: PublicNumber -> PublicNumber -> Bool Source #

(>=) :: PublicNumber -> PublicNumber -> Bool Source #

max :: PublicNumber -> PublicNumber -> PublicNumber Source #

min :: PublicNumber -> PublicNumber -> PublicNumber Source #

Read PublicNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods readsPrec :: Int -> ReadS PublicNumber Source # readList :: ReadS [PublicNumber] Source # readPrec :: ReadPrec PublicNumber Source # readListPrec :: ReadPrec [PublicNumber] Source #
Real PublicNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods toRational :: PublicNumber -> Rational Source #
Show PublicNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods showsPrec :: Int -> PublicNumber -> ShowS Source # show :: PublicNumber -> String Source # showList :: [PublicNumber] -> ShowS Source #

data PrivateNumber Source #

Represent Diffie Hellman private number X.

Instances

Enum PrivateNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

succ :: PrivateNumber -> PrivateNumber Source #

pred :: PrivateNumber -> PrivateNumber Source #

toEnum :: Int -> PrivateNumber Source #

fromEnum :: PrivateNumber -> Int Source #

enumFrom :: PrivateNumber -> [PrivateNumber] Source #

enumFromThen :: PrivateNumber -> PrivateNumber -> [PrivateNumber] Source #

enumFromTo :: PrivateNumber -> PrivateNumber -> [PrivateNumber] Source #

enumFromThenTo :: PrivateNumber -> PrivateNumber -> PrivateNumber -> [PrivateNumber] Source #

Eq PrivateNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods (==) :: PrivateNumber -> PrivateNumber -> Bool Source # (/=) :: PrivateNumber -> PrivateNumber -> Bool Source #
Num PrivateNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

(+) :: PrivateNumber -> PrivateNumber -> PrivateNumber Source #

(-) :: PrivateNumber -> PrivateNumber -> PrivateNumber Source #

(*) :: PrivateNumber -> PrivateNumber -> PrivateNumber Source #

negate :: PrivateNumber -> PrivateNumber Source #

abs :: PrivateNumber -> PrivateNumber Source #

signum :: PrivateNumber -> PrivateNumber Source #

fromInteger :: Integer -> PrivateNumber Source #

Ord PrivateNumber |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

compare :: PrivateNumber -> PrivateNumber -> Ordering Source #

(<) :: PrivateNumber -> PrivateNumber -> Bool Source #

(<=) :: PrivateNumber -> PrivateNumber -> Bool Source #

(>) :: PrivateNumber -> PrivateNumber -> Bool Source #

(>=) :: PrivateNumber -> PrivateNumber -> Bool Source #

max :: PrivateNumber -> PrivateNumber -> PrivateNumber Source #

min :: PrivateNumber -> PrivateNumber -> PrivateNumber Source #

Read PrivateNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods readsPrec :: Int -> ReadS PrivateNumber Source # readList :: ReadS [PrivateNumber] Source # readPrec :: ReadPrec PrivateNumber Source # readListPrec :: ReadPrec [PrivateNumber] Source #
Real PrivateNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods toRational :: PrivateNumber -> Rational Source #
Show PrivateNumber |
Instance details Defined in Crypto.Types.PubKey.DH Methods showsPrec :: Int -> PrivateNumber -> ShowS Source # show :: PrivateNumber -> String Source # showList :: [PrivateNumber] -> ShowS Source #

data SharedKey Source #

Represent Diffie Hellman shared secret.

Instances

Enum SharedKey |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

succ :: SharedKey -> SharedKey Source #

pred :: SharedKey -> SharedKey Source #

toEnum :: Int -> SharedKey Source #

fromEnum :: SharedKey -> Int Source #

enumFrom :: SharedKey -> [SharedKey] Source #

enumFromThen :: SharedKey -> SharedKey -> [SharedKey] Source #

enumFromTo :: SharedKey -> SharedKey -> [SharedKey] Source #

enumFromThenTo :: SharedKey -> SharedKey -> SharedKey -> [SharedKey] Source #

Eq SharedKey |
Instance details Defined in Crypto.Types.PubKey.DH Methods (==) :: SharedKey -> SharedKey -> Bool Source # (/=) :: SharedKey -> SharedKey -> Bool Source #
Num SharedKey |
Instance details Defined in Crypto.Types.PubKey.DH Methods (+) :: SharedKey -> SharedKey -> SharedKey Source # (-) :: SharedKey -> SharedKey -> SharedKey Source # (*) :: SharedKey -> SharedKey -> SharedKey Source # negate :: SharedKey -> SharedKey Source # abs :: SharedKey -> SharedKey Source # signum :: SharedKey -> SharedKey Source # fromInteger :: Integer -> SharedKey Source #
Ord SharedKey |

Instance details

Defined in Crypto.Types.PubKey.DH

Methods

compare :: SharedKey -> SharedKey -> Ordering Source #

(<) :: SharedKey -> SharedKey -> Bool Source #

(<=) :: SharedKey -> SharedKey -> Bool Source #

(>) :: SharedKey -> SharedKey -> Bool Source #

(>=) :: SharedKey -> SharedKey -> Bool Source #

max :: SharedKey -> SharedKey -> SharedKey Source #

min :: SharedKey -> SharedKey -> SharedKey Source #

Read SharedKey |
Instance details Defined in Crypto.Types.PubKey.DH Methods readsPrec :: Int -> ReadS SharedKey Source # readList :: ReadS [SharedKey] Source # readPrec :: ReadPrec SharedKey Source # readListPrec :: ReadPrec [SharedKey] Source #
Real SharedKey |
Instance details Defined in Crypto.Types.PubKey.DH Methods toRational :: SharedKey -> Rational Source #
Show SharedKey |
Instance details Defined in Crypto.Types.PubKey.DH Methods showsPrec :: Int -> SharedKey -> ShowS Source # show :: SharedKey -> String Source # showList :: [SharedKey] -> ShowS Source #

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