OpenBSD manual page server

Manual Page Search Parameters

DH_GET0_PQG(3) Library Functions Manual DH_GET0_PQG(3)

DH_get0_pqg, DH_set0_pqg, DH_get0_key, DH_set0_key, DH_clear_flags, DH_test_flags, DH_set_flags, DH_get0_engine, DH_set_lengthget data from and set data in a DH object

#include <openssl/dh.h>

void
DH_get0_pqg(const DH *dh, const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);

int
DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);

void
DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key);

int
DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);

void
DH_clear_flags(DH *dh, int flags);

int
DH_test_flags(const DH *dh, int flags);

void
DH_set_flags(DH *dh, int flags);

ENGINE *
DH_get0_engine(DH *d);

int
DH_set_length(DH *dh, long length);

A DH object contains the parameters p, g, and optionally q. It also contains a public key pub_key and an optional private key priv_key.

The p, q, and g parameters can be obtained by calling (). If the parameters have not yet been set, then *p, *q, and *g are set to NULL. Otherwise, they are set to pointers to the internal representations of the values that should not be freed by the application. Any of the out parameters p, q, and g can be NULL, in which case no value is returned for that parameter.

The p, q, and g values can be set by calling (). Calling this function transfers the memory management of the values to dh, and therefore they should not be freed by the caller. The q argument may be NULL.

The () function stores pointers to the internal representations of the public key in *pub_key and to the private key in *priv_key. Either may be NULL if it has not yet been set. If the private key has been set, then the public key must be. Any of the out parameters pub_key and priv_key can be NULL, in which case no value is returned for that parameter.

The public and private key values can be set using (). Either parameter may be NULL, which means the corresponding DH field is left untouched. This function transfers the memory management of the key values to dh, and therefore they should not be freed by the caller.

Values retrieved with () and DH_get0_key() are owned by the DH object and may therefore not be passed to DH_set0_pqg() or DH_set0_key(). If needed, duplicate the received values using BN_dup(3) and pass the duplicates.

() clears the specified flags in dh. () tests the flags in dh. () sets the flags in dh; any flags already set remain set. For all three functions, multiple flags can be passed in one call, OR'ed together bitwise.

() sets the optional length attribute of dh, indicating the length of the secret exponent (private key) in bits. If the length attribute is non-zero, it is used, otherwise it is ignored.

DH_set0_pqg(), DH_set0_key(), and DH_set_length() return 1 on success or 0 on failure.

DH_test_flags() return those of the given flags currently set in dh or 0 if none of the given flags are set.

DH_get0_engine() returns a pointer to the ENGINE used by the DH object dh, or NULL if no engine was set for this object.

DH_generate_key(3), DH_generate_parameters(3), DH_new(3), DH_size(3), DHparams_print(3)

These functions first appeared in OpenSSL 1.1.0 and have been available since OpenBSD 6.3.

December 21, 2018 OpenBSD-6.9