DSA(3BM)

NAME
DSASign, DSAVerify, randBytesNeededForDSAParams, randBytesNeededForDSAKeySet, randBytesNeededForDSASign

SYNOPSIS
#include <libcrypt.h>

int randBytesNeededForDSAParams(int primebits, int facbits)

int randBytesNeededForDSAKeySet(int facbits)

int randBytesNeededForDSASign(int facbits)

DSAParams *genDSAParams(int primebits, int facbits, BigInt randomStart)

DSAKeySet *genDSAKeySet(DSAParams *params, int pbits, int qbits, BigInt randomStart)

DSASignature *DSASign(BigInt m, DSAPrivateKey *key, BigInt randomStart)

DSASignature *quantized_DSASign(BigInt m, DSAPrivateKey *key, BigInt randomStart)

Boolean DSAVerify(BigInt m, DSASignature *sig, DSAPublicKey *key)

DESCRIPTION

For all of these functions $BigInt$ arguments are assumed to be initialized $BigInts$. $bigInit(0)$ should be used for initialization of empty $BigInts$. If more space is needed than is provided the functions themselves take care of the space allocation. In all of the function which have an argument, $randomStart$, if this argument is chosen NULL, the default, DES-based pseudo-RNG seeded with truerand() will be used to generate necessary random material. If $randomStart$ is not NULL, the accompanying functions, randBytesNeededForEG... are used to find out how many random bytes are expected. In all above functions, $primebits$ is the number of bits in the modulus, and $facbits$ is the number of bits in $p - 1$. Typically these are 1024 and 160 respectively. $genDSAParams$ generates a prime p, a prime factor of p-1, and a primitive root mod p. It is sometimes the case that large groups will use the same set of parameters. This is the reason for decoupling this from the genKeySet routine which actually generates the secret exponent and public and private keys. These functions create digital signatures along the guidelines proposed by the National Institute of Standards and Technology (NIST). The cryptosystem is a variant of El Gamal systems. The keys are the same as those used by our implementation of the El Gamal system (actually the El Gamal implementation uses the key scheme suggested by NIST and Schnorr). $DSASign$ generates a digital signature for message $m$ using a private key. The quantized version use STD_QUANTUM milliseconds as the quantum for execution to defend against Kocher-style timing attacks. STD_QUANTUM is defined in libcrypt.h and should be tuned to your environment. $DSAVerify$ verifies that a signature received with a message $m$ is valid using the public key which corresponds to the private key used to generate the signature.

Usage example:

randbytes = randBytesNeededForDSAParams(1024, 160);

BigInt randomStart = bigInit(0);

bigRand(randbytes, randomStart, PSEUDO);

params = genDSAParams(1024, 160, randomStart);

randbytes = randBytesNeededForDSAKeySet(160);

bigRand(randbytes, randomStart, PSEUDO);

DSAKeys = genDSAKeySet(params, 1024, 160, randomStart);

To sign the SHS digest of file "foo":

randbytes = randBytesNeededForDSASign(160);

bigRand(randbytes, randomStart, PSEUDO);

BigInt mdigest = bigInit(0);

BigMessageDigest("foo", mdigest, SHS);

DSAsig = DSASign(mdigest, DSAKeys->DSAPrivateKey, randomStart);

To verify:

BigInt mdigest = bigInit(0);

BigMessageDigest("foo", mdigest, SHS);

Boolean verify = DSAVerify(mdigest, DSAsig, DSAKeys->DSAPublicKey);

SEE ALSO
bigInit(3BM), bigTest(3BM), bigBits(3BM), bigToBuf(3BM), bufToBig(3BM), fBigPrint(3BM), atobig(3BM), bigPow(3BM), EGSign(3BM), EGVerify(3BM), genStrongPrimeSet(3BM) start_quantize(3BM) end_quantize(3BM)