The Digital Signature Algorithm (FIPS 186-2). See http://www.openssl.org/docs/crypto/dsa.html
- class DSAKey k where
- data DSAPubKey
- data DSAKeyPair
- generateDSAParameters :: Int -> Maybe ByteString -> IO (Int, Int, Integer, Integer, Integer)
- generateDSAKey :: Integer -> Integer -> Integer -> IO DSAKeyPair
- generateDSAParametersAndKey :: Int -> Maybe ByteString -> IO DSAKeyPair
- signDigestedDataWithDSA :: DSAKeyPair -> ByteString -> IO (Integer, Integer)
- verifyDigestedDataWithDSA :: DSAKey k => k -> ByteString -> (Integer, Integer) -> IO Bool
- dsaPrivate :: DSAKeyPair -> Integer
- dsaPubKeyToTuple :: DSAKeyPair -> (Integer, Integer, Integer, Integer)
- dsaKeyPairToTuple :: DSAKeyPair -> (Integer, Integer, Integer, Integer, Integer)
- tupleToDSAPubKey :: (Integer, Integer, Integer, Integer) -> DSAPubKey
- tupleToDSAKeyPair :: (Integer, Integer, Integer, Integer, Integer) -> DSAKeyPair
Type
is either DSAKey
aDSAPubKey
or DSAKeyPair
.
Return the length of key.
Return the public prime number of the key.
Return the public 160-bit subprime, q | p - 1
of the key.
Return the public generator of subgroup of the key.
dsaPublic :: k -> IntegerSource
Return the public key y = g^x
.
withDSAPtr :: k -> (Ptr DSA -> IO a) -> IO aSource
The type of a DSA public key, includes parameters p, q, g and public.
data DSAKeyPair Source
The type of a DSA keypair, includes parameters p, q, g, public and private.
Key and parameter generation
:: Int | The number of bits in the generated prime: 512 <= x <= 1024 |
-> Maybe ByteString | optional seed, its length must be 20 bytes |
-> IO (Int, Int, Integer, Integer, Integer) | (iteration count, generator count, p, q, g) |
Generate DSA parameters (*not* a key, but required for a key). This is a compute intensive operation. See FIPS 186-2, app 2. This agrees with the test vectors given in FIP 186-2, app 5
:: Integer | p |
-> Integer | q |
-> Integer | g |
-> IO DSAKeyPair |
Generate a new DSA keypair, given valid parameters
generateDSAParametersAndKeySource
:: Int | The number of bits in the generated prime: 512 <= x <= 1024 |
-> Maybe ByteString | optional seed, its length must be 20 bytes |
-> IO DSAKeyPair |
A utility function to generate both the parameters and the key pair at the same time. Saves serialising and deserialising the parameters too
Signing and verification
signDigestedDataWithDSA :: DSAKeyPair -> ByteString -> IO (Integer, Integer)Source
Sign pre-digested data. The DSA specs call for SHA1 to be used so, if you use anything else, YMMV. Returns a pair of Integers which, together, are the signature
verifyDigestedDataWithDSA :: DSAKey k => k -> ByteString -> (Integer, Integer) -> IO BoolSource
Verify pre-digested data given a signature.
Extracting fields of DSA objects
dsaPrivate :: DSAKeyPair -> IntegerSource
Return the private key x
.
dsaPubKeyToTuple :: DSAKeyPair -> (Integer, Integer, Integer, Integer)Source
Convert a DSAPubKey object to a tuple of its members in the order p, q, g, and public.
dsaKeyPairToTuple :: DSAKeyPair -> (Integer, Integer, Integer, Integer, Integer)Source
Convert a DSAKeyPair object to a tuple of its members in the order p, q, g, public and private.
tupleToDSAPubKey :: (Integer, Integer, Integer, Integer) -> DSAPubKeySource
Convert a tuple of members (in the same format as from
dsaPubKeyToTuple
) into a DSAPubKey object
tupleToDSAKeyPair :: (Integer, Integer, Integer, Integer, Integer) -> DSAKeyPairSource
Convert a tuple of members (in the same format as from
dsaPubKeyToTuple
) into a DSAPubKey object