NAME
DHgenerateparameters, DHcheck - generate and check Diffie-Hellman
parametersSYNOPSIS
#include
DH *DHgenerateparameters(int primelen, int generator, void (*callback)(int, int, void *), void *cbarg); int DHcheck(DH *dh, int *codes);DESCRIPTION
DHgenerateparameters() generates Diffie-Hellman parameters that can
be shared among a group of users, and returns them in a newly allocatedDDHH structure. The pseudo-random number generator must be seeded prior
to calling DHgenerateparameters(). pprriimmeelleenn is the length in bits of the safe prime to be generated. ggeenneerraattoorr is a small number > 1, typically 2 or 5. A callback function may be used to provide feedback about the progress of the key generation. If ccaallllbbaacckk is not NNUULLLL, it will be called as described in BNgenerateprime(3) while a random prime number is generated, and when a prime has been found, ccaallllbbaacckk((33,, 00,, ccbbaarrgg)) is called.DHcheck() validates Diffie-Hellman parameters. It checks that pp is a
safe prime, and that gg is a suitable generator. In the case of an error, the bit flags DHCHECKPNOTSAFEPRIME or DHNOTSUITABLEGENERATOR are set in **ccooddeess. DHUNABLETOCHECKGENERATOR is set if the generator cannot be checked, i.e. it does not equal 2 or 5.RETURN VALUES
DHgenerateparameters() returns a pointer to the DH structure, or NULL if the parameter generation fails. The error codes can be obtained by ERRgeterror(3). DHcheck() returns 1 if the check could be performed, 0 otherwise. NNOOTTEESS DHgenerateparameters() may run for several hours before finding a suitable prime. The parameters generated by DHgenerateparameters() are not to be used in signature schemes.BUGS
If ggeenneerraattoorr is not 2 or 5, ddhh->>gg=ggeenneerraattoorr is not a usable generator.
SEE ALSO
dh(3), ERRgeterror(3), rand(3), DHfree(3) HISTORY DHcheck() is available in all versions of SSLeay and OpenSSL. The ccbbaarrgg argument to DHgenerateparameters() was added in SSLeay 0.9.0. In versions before OpenSSL 0.9.5, DHCHECKPNOTSTRONGPRIME is used instead of DHCHECKPNOTSAFEPRIME.0.9.7l 2002-09-25 DHgenerateparameters(3)