NAME
dh - Diffie-Hellman key agreement
SYNOPSIS
#include
#include
DH * DHnew(void);void DHfree(DH *dh);
int DHsize(const DH *dh);
DH * DHgenerateparameters(int primelen, int generator, void (*callback)(int, int, void *), void *cbarg);int DHcheck(const DH *dh, int *codes);
int DHgeneratekey(DH *dh);
int DHcomputekey(unsigned char *key, BIGNUM *pubkey, DH *dh);
void DHsetdefaultmethod(const DHMETHOD *meth); const DHMETHOD *DHgetdefaultmethod(void);int DHsetmethod(DH *dh, const DHMETHOD *meth);
DH *DHnewmethod(ENGINE *engine); const DHMETHOD *DHOpenSSL(void); int DHgetexnewindex(long argl, char *argp, int (*newfunc)(), int (*dupfunc)(), void (*freefunc)()); int DHsetexdata(DH *d, int idx, char *arg); char *DHgetexdata(DH *d, int idx); DH * d2iDHparams(DH **a, unsigned char **pp, long length); int i2dDHparams(const DH *a, unsigned char **pp); int DHparamsprintfp(FILE *fp, const DH *x); int DHparamsprint(BIO *bp, const DH *x);DESCRIPTION
These functions implement the Diffie-Hellman key agreement protocol.
The generation of shared DH parameters is described in DHgenerateparameters(3); DHgeneratekey(3) describes how to perform a key agreement. The DDHH structure consists of several BIGNUM components. struct { BIGNUM *p; // prime number (shared) BIGNUM *g; // generator of Zp (shared) BIGNUM *privkey; // private DH value x BIGNUM *pubkey; // public DH value g^x // ... }; DHNote that DH keys may use non-standard DDHHMMEETTHHOODD implementations,
either directly or by the use of EENNGGIINNEE modules. In some cases (eg. anENGINE providing support for hardware-embedded keys), these BIGNUM
values will not be used by the implementation or may be used for alternative data storage. For this reason, applications should generally avoid using DH structure elements directly and instead use API functions to query or modify keys.SEE ALSO
dhparam(1), bn(3), dsa(3), err(3), rand(3), rsa(3), engine(3),
DHsetmethod(3), DHnew(3), DHgetexnewindex(3), DHgenerateparameters(3), DHcomputekey(3), d2iDHparams(3), RSAprint(3)0.9.7l 2002-08-05 dh(3)