HsOpenSSL-0.3: (Part of) OpenSSL binding for HaskellContentsIndex
OpenSSL.DSA
Contents
Type
Key and parameter generation
Signing and verification
Extracting fields of DSA objects
Description
The Digital Signature Algorithm (FIPS 186-2). See http://www.openssl.org/docs/crypto/dsa.html
Synopsis
data DSA
generateParameters :: Int -> Maybe ByteString -> IO (Int, Int, Integer, Integer, Integer)
generateKey :: Integer -> Integer -> Integer -> IO DSA
generateParametersAndKey :: Int -> Maybe ByteString -> IO DSA
signDigestedData :: DSA -> ByteString -> IO (Integer, Integer)
verifyDigestedData :: DSA -> ByteString -> (Integer, Integer) -> IO Bool
dsaP :: DSA -> IO (Maybe Integer)
dsaQ :: DSA -> IO (Maybe Integer)
dsaG :: DSA -> IO (Maybe Integer)
dsaPrivate :: DSA -> IO (Maybe Integer)
dsaPublic :: DSA -> IO (Maybe Integer)
dsaToTuple :: DSA -> IO (Integer, Integer, Integer, Integer, Maybe Integer)
tupleToDSA :: (Integer, Integer, Integer, Integer, Maybe Integer) -> IO DSA
Type
data DSA
The type of a DSA key, includes parameters p, q, g.
Key and parameter generation
generateParameters
:: IntThe number of bits in the generated prime: 512 <= x <= 1024
-> Maybe ByteStringoptional 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
generateKey
:: Integerp
-> Integerq
-> Integerg
-> IO DSA
Generate a new DSA key, given valid parameters
generateParametersAndKey
:: IntThe number of bits in the generated prime: 512 <= x <= 1024
-> Maybe ByteStringoptional seed, its length must be 20 bytes
-> IO DSA
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
signDigestedData :: DSA -> ByteString -> IO (Integer, Integer)
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
verifyDigestedData :: DSA -> ByteString -> (Integer, Integer) -> IO Bool
Verify pre-digested data given a signature.
Extracting fields of DSA objects
dsaP :: DSA -> IO (Maybe Integer)
Return the public prime number of the key.
dsaQ :: DSA -> IO (Maybe Integer)
Return the public 160-bit subprime, q | p-1 of the key.
dsaG :: DSA -> IO (Maybe Integer)
Return the public generator of subgroup of the key.
dsaPrivate :: DSA -> IO (Maybe Integer)
Return the private key x.
dsaPublic :: DSA -> IO (Maybe Integer)
Return the public key y = g^x.
dsaToTuple :: DSA -> IO (Integer, Integer, Integer, Integer, Maybe Integer)
Convert a DSA object to a tuple of its members in the order p, q, g, public, private. If this is a public key, private will be Nothing
tupleToDSA :: (Integer, Integer, Integer, Integer, Maybe Integer) -> IO DSA
Convert a tuple of members (in the same format as from dsaToTuple) into a DSA object
Produced by Haddock version 0.8