Blame doc/man3/DH_get0_pqg.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
DH_get0_pqg, DH_set0_pqg, DH_get0_key, DH_set0_key,
Packit c4476c
DH_get0_p, DH_get0_q, DH_get0_g,
Packit c4476c
DH_get0_priv_key, DH_get0_pub_key,
Packit c4476c
DH_clear_flags, DH_test_flags, DH_set_flags, DH_get0_engine,
Packit c4476c
DH_get_length, DH_set_length - Routines for getting and setting data in a DH object
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/dh.h>
Packit c4476c
Packit c4476c
 void DH_get0_pqg(const DH *dh,
Packit c4476c
                  const BIGNUM **p, const BIGNUM **q, const BIGNUM **g);
Packit c4476c
 int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g);
Packit c4476c
 void DH_get0_key(const DH *dh,
Packit c4476c
                  const BIGNUM **pub_key, const BIGNUM **priv_key);
Packit c4476c
 int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key);
Packit c4476c
 const BIGNUM *DH_get0_p(const DH *dh);
Packit c4476c
 const BIGNUM *DH_get0_q(const DH *dh);
Packit c4476c
 const BIGNUM *DH_get0_g(const DH *dh);
Packit c4476c
 const BIGNUM *DH_get0_priv_key(const DH *dh);
Packit c4476c
 const BIGNUM *DH_get0_pub_key(const DH *dh);
Packit c4476c
 void DH_clear_flags(DH *dh, int flags);
Packit c4476c
 int DH_test_flags(const DH *dh, int flags);
Packit c4476c
 void DH_set_flags(DH *dh, int flags);
Packit c4476c
 ENGINE *DH_get0_engine(DH *d);
Packit c4476c
 long DH_get_length(const DH *dh);
Packit c4476c
 int DH_set_length(DH *dh, long length);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
A DH object contains the parameters B

, B<q> and B<g>. Note that the B<q>

Packit c4476c
parameter is optional. It also contains a public key (B<pub_key>) and
Packit c4476c
(optionally) a private key (B<priv_key>).
Packit c4476c
Packit c4476c
The B

, B<q> and B<g> parameters can be obtained by calling DH_get0_pqg().

Packit c4476c
If the parameters have not yet been set then B<*p>, B<*q> and B<*g> will be set
Packit c4476c
to NULL. Otherwise they are set to pointers to their respective values. These
Packit c4476c
point directly to the internal representations of the values and therefore
Packit c4476c
should not be freed directly.
Packit c4476c
Any of the out parameters B

, B<q>, and B<g> can be NULL, in which case no

Packit c4476c
value will be returned for that parameter.
Packit c4476c
Packit c4476c
The B

, B<q> and B<g> values can be set by calling DH_set0_pqg() and passing

Packit c4476c
the new values for B

, B<q> and B<g> as parameters to the function. Calling

Packit c4476c
this function transfers the memory management of the values to the DH object,
Packit c4476c
and therefore the values that have been passed in should not be freed directly
Packit c4476c
after this function has been called. The B<q> parameter may be NULL.
Packit c4476c
Packit c4476c
To get the public and private key values use the DH_get0_key() function. A
Packit c4476c
pointer to the public key will be stored in B<*pub_key>, and a pointer to the
Packit c4476c
private key will be stored in B<*priv_key>. Either may be NULL if they have not
Packit c4476c
been set yet, although if the private key has been set then the public key must
Packit c4476c
be. The values point to the internal representation of the public key and
Packit c4476c
private key values. This memory should not be freed directly.
Packit c4476c
Any of the out parameters B<pub_key> and B<priv_key> can be NULL, in which case
Packit c4476c
no value will be returned for that parameter.
Packit c4476c
Packit c4476c
The public and private key values can be set using DH_set0_key(). Either
Packit c4476c
parameter may be NULL, which means the corresponding DH field is left
Packit c4476c
untouched. As with DH_set0_pqg() this function transfers the memory management
Packit c4476c
of the key values to the DH object, and therefore they should not be freed
Packit c4476c
directly after this function has been called.
Packit c4476c
Packit c4476c
Any of the values B

, B<q>, B<g>, B<priv_key>, and B<pub_key> can also be

Packit c4476c
retrieved separately by the corresponding function DH_get0_p(), DH_get0_q(),
Packit c4476c
DH_get0_g(), DH_get0_priv_key(), and DH_get0_pub_key(), respectively.
Packit c4476c
Packit c4476c
DH_set_flags() sets the flags in the B<flags> parameter on the DH object.
Packit c4476c
Multiple flags can be passed in one go (bitwise ORed together). Any flags that
Packit c4476c
are already set are left set. DH_test_flags() tests to see whether the flags
Packit c4476c
passed in the B<flags> parameter are currently set in the DH object. Multiple
Packit c4476c
flags can be tested in one go. All flags that are currently set are returned, or
Packit c4476c
zero if none of the flags are set. DH_clear_flags() clears the specified flags
Packit c4476c
within the DH object.
Packit c4476c
Packit c4476c
DH_get0_engine() returns a handle to the ENGINE that has been set for this DH
Packit c4476c
object, or NULL if no such ENGINE has been set.
Packit c4476c
Packit c4476c
The DH_get_length() and DH_set_length() functions get and set the optional
Packit c4476c
length parameter associated with this DH object. If the length is non-zero then
Packit c4476c
it is used, otherwise it is ignored. The B<length> parameter indicates the
Packit c4476c
length of the secret exponent (private key) in bits.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
Values retrieved with DH_get0_key() are owned by the DH object used
Packit c4476c
in the call and may therefore I<not> be passed to DH_set0_key().  If
Packit c4476c
needed, duplicate the received value using BN_dup() and pass the
Packit c4476c
duplicate.  The same applies to DH_get0_pqg() and DH_set0_pqg().
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
DH_set0_pqg() and DH_set0_key() return 1 on success or 0 on failure.
Packit c4476c
Packit c4476c
DH_get0_p(), DH_get0_q(), DH_get0_g(), DH_get0_priv_key(), and DH_get0_pub_key()
Packit c4476c
return the respective value, or NULL if it is unset.
Packit c4476c
Packit c4476c
DH_test_flags() returns the current state of the flags in the DH object.
Packit c4476c
Packit c4476c
DH_get0_engine() returns the ENGINE set for the DH object or NULL if no ENGINE
Packit c4476c
has been set.
Packit c4476c
Packit c4476c
DH_get_length() returns the length of the secret exponent (private key) in bits,
Packit c4476c
or zero if no such length has been explicitly set.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<DH_new(3)>, L<DH_new(3)>, L<DH_generate_parameters(3)>, L<DH_generate_key(3)>,
Packit c4476c
L<DH_set_method(3)>, L<DH_size(3)>, L<DH_meth_new(3)>
Packit c4476c
Packit c4476c
=head1 HISTORY
Packit c4476c
Packit c4476c
The functions described here were added in OpenSSL 1.1.0.
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut