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

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 |
Instance details Defined in Crypto.Types.PubKey.DSA Methods (==) :: Params -> Params -> Bool Source # (/=) :: Params -> Params -> Bool Source #
Data Params |

Instance details

Defined in Crypto.Types.PubKey.DSA

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.DSA 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.DSA Methods showsPrec :: Int -> Params -> ShowS Source # show :: Params -> String Source # showList :: [Params] -> ShowS Source #
ASN1Object Params |
Instance details Defined in Crypto.Types.PubKey.DSA Methods toASN1 :: Params -> ASN1S fromASN1 :: [ASN1] -> Either String (Params, [ASN1])

data Signature Source #

Represent a DSA signature namely R and S.

Constructors

Signature |

Fields

- sign_r :: Integer

  DSA r

- sign_s :: Integer

  DSA s

Instances

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

Instance details

Defined in Crypto.Types.PubKey.DSA

Methods

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

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

toConstr :: Signature -> Constr Source #

dataTypeOf :: Signature -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

data PublicKey Source #

Represent a DSA public key.

Constructors

PublicKey |

Fields

- public_params :: Params

  DSA parameters

- public_y :: PublicNumber

  DSA public Y

Instances

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

Instance details

Defined in Crypto.Types.PubKey.DSA

Methods

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

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

toConstr :: PublicKey -> Constr Source #

dataTypeOf :: PublicKey -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

data PrivateKey Source #

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 |
Instance details Defined in Crypto.Types.PubKey.DSA Methods (==) :: PrivateKey -> PrivateKey -> Bool Source # (/=) :: PrivateKey -> PrivateKey -> Bool Source #
Data PrivateKey |

Instance details

Defined in Crypto.Types.PubKey.DSA

Methods

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

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

toConstr :: PrivateKey -> Constr Source #

dataTypeOf :: PrivateKey -> DataType Source #

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

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

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

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

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

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

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

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

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

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

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

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