License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | Good |
Safe Haskell | None |
Language | Haskell2010 |
An implementation of the Digital Signature Algorithm (DSA)
- data Params = Params {}
- data Signature = Signature {}
- data PublicKey = PublicKey {}
- data PrivateKey = PrivateKey {}
- type PublicNumber = Integer
- type PrivateNumber = Integer
- generatePrivate :: MonadRandom m => Params -> m PrivateNumber
- calculatePublic :: Params -> PrivateNumber -> PublicNumber
- sign :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature
- signWith :: (ByteArrayAccess msg, HashAlgorithm hash) => Integer -> PrivateKey -> hash -> msg -> Maybe Signature
- verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool
- data KeyPair = KeyPair Params PublicNumber PrivateNumber
- toPublicKey :: KeyPair -> PublicKey
- toPrivateKey :: KeyPair -> PrivateKey
Documentation
Represent DSA parameters namely P, G, and Q.
Represent a DSA signature namely R and S.
Represent a DSA public key.
PublicKey | |
|
data PrivateKey Source
Represent a DSA private key.
Only x need to be secret. the DSA parameters are publicly shared with the other side.
PrivateKey | |
|
type PublicNumber = Integer Source
DSA Public Number, usually embedded in DSA Public Key
type PrivateNumber = Integer Source
DSA Private Number, usually embedded in DSA Private Key
generation
generatePrivate :: MonadRandom m => Params -> m PrivateNumber 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 :: (ByteArrayAccess msg, HashAlgorithm hash, MonadRandom m) => PrivateKey -> hash -> msg -> m Signature Source
sign message using the private key.
:: (ByteArrayAccess msg, HashAlgorithm hash) | |
=> Integer | k random number |
-> PrivateKey | private key |
-> hash | hash function |
-> msg | message to sign |
-> Maybe Signature |
sign message using the private key and an explicit k number.
verification primitive
verify :: (ByteArrayAccess msg, HashAlgorithm hash) => hash -> PublicKey -> Signature -> msg -> Bool Source
verify a bytestring using the public key.
Key pair
Represent a DSA key pair
toPublicKey :: KeyPair -> PublicKey Source
Public key of a DSA Key pair
toPrivateKey :: KeyPair -> PrivateKey Source
Private key of a DSA Key pair