xref: /openbsd-src/lib/libcrypto/man/DH_new.3 (revision dd550453c6f848bdeef8e7dd9ef1862581c51353)
1*dd550453Sschwarze.\"	$OpenBSD: DH_new.3,v 1.12 2022/07/13 21:51:35 schwarze Exp $
2b019edfaSschwarze.\"	OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
38974101aSjmc.\"
4b019edfaSschwarze.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5b019edfaSschwarze.\" Copyright (c) 2000 The OpenSSL Project.  All rights reserved.
6b019edfaSschwarze.\"
7b019edfaSschwarze.\" Redistribution and use in source and binary forms, with or without
8b019edfaSschwarze.\" modification, are permitted provided that the following conditions
9b019edfaSschwarze.\" are met:
10b019edfaSschwarze.\"
11b019edfaSschwarze.\" 1. Redistributions of source code must retain the above copyright
12b019edfaSschwarze.\"    notice, this list of conditions and the following disclaimer.
13b019edfaSschwarze.\"
14b019edfaSschwarze.\" 2. Redistributions in binary form must reproduce the above copyright
15b019edfaSschwarze.\"    notice, this list of conditions and the following disclaimer in
16b019edfaSschwarze.\"    the documentation and/or other materials provided with the
17b019edfaSschwarze.\"    distribution.
18b019edfaSschwarze.\"
19b019edfaSschwarze.\" 3. All advertising materials mentioning features or use of this
20b019edfaSschwarze.\"    software must display the following acknowledgment:
21b019edfaSschwarze.\"    "This product includes software developed by the OpenSSL Project
22b019edfaSschwarze.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23b019edfaSschwarze.\"
24b019edfaSschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25b019edfaSschwarze.\"    endorse or promote products derived from this software without
26b019edfaSschwarze.\"    prior written permission. For written permission, please contact
27b019edfaSschwarze.\"    openssl-core@openssl.org.
28b019edfaSschwarze.\"
29b019edfaSschwarze.\" 5. Products derived from this software may not be called "OpenSSL"
30b019edfaSschwarze.\"    nor may "OpenSSL" appear in their names without prior written
31b019edfaSschwarze.\"    permission of the OpenSSL Project.
32b019edfaSschwarze.\"
33b019edfaSschwarze.\" 6. Redistributions of any form whatsoever must retain the following
34b019edfaSschwarze.\"    acknowledgment:
35b019edfaSschwarze.\"    "This product includes software developed by the OpenSSL Project
36b019edfaSschwarze.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37b019edfaSschwarze.\"
38b019edfaSschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39b019edfaSschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40b019edfaSschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41b019edfaSschwarze.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42b019edfaSschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43b019edfaSschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44b019edfaSschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45b019edfaSschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46b019edfaSschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47b019edfaSschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48b019edfaSschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49b019edfaSschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50b019edfaSschwarze.\"
51*dd550453Sschwarze.Dd $Mdocdate: July 13 2022 $
52526c24c9Sschwarze.Dt DH_NEW 3
53526c24c9Sschwarze.Os
54526c24c9Sschwarze.Sh NAME
55526c24c9Sschwarze.Nm DH_new ,
56b2df81b8Sschwarze.Nm DH_up_ref ,
57526c24c9Sschwarze.Nm DH_free
58526c24c9Sschwarze.Nd allocate and free DH objects
59526c24c9Sschwarze.Sh SYNOPSIS
60526c24c9Sschwarze.In openssl/dh.h
61526c24c9Sschwarze.Ft DH*
62526c24c9Sschwarze.Fn DH_new void
63b2df81b8Sschwarze.Ft int
64b2df81b8Sschwarze.Fo DH_up_ref
65b2df81b8Sschwarze.Fa "DH *dh"
66b2df81b8Sschwarze.Fc
67526c24c9Sschwarze.Ft void
68526c24c9Sschwarze.Fo DH_free
69526c24c9Sschwarze.Fa "DH *dh"
70526c24c9Sschwarze.Fc
71526c24c9Sschwarze.Sh DESCRIPTION
727e67b9f1SschwarzeThe DH functions implement the Diffie-Hellman key agreement protocol.
737e67b9f1Sschwarze.Pp
74526c24c9Sschwarze.Fn DH_new
75526c24c9Sschwarzeallocates and initializes a
76526c24c9Sschwarze.Vt DH
77b2df81b8Sschwarzestructure, setting the reference count to 1.
78b2df81b8SschwarzeIt is equivalent to
79b2df81b8Sschwarze.Xr DH_new_method 3
80b2df81b8Sschwarzewith a
81b2df81b8Sschwarze.Dv NULL
82b2df81b8Sschwarzeargument.
83b2df81b8Sschwarze.Pp
84b2df81b8Sschwarze.Fn DH_up_ref
85b2df81b8Sschwarzeincrements the reference count by 1.
86526c24c9Sschwarze.Pp
87526c24c9Sschwarze.Fn DH_free
88b2df81b8Sschwarzedecrements the reference count by 1.
89b2df81b8SschwarzeIf it reaches 0, it frees the
90526c24c9Sschwarze.Vt DH
91526c24c9Sschwarzestructure and its components.
92526c24c9SschwarzeThe values are erased before the memory is returned to the system.
93b019edfaSschwarzeIf
94b019edfaSschwarze.Fa dh
95b019edfaSschwarzeis a
96b019edfaSschwarze.Dv NULL
97b019edfaSschwarzepointer, no action occurs.
98526c24c9Sschwarze.Sh RETURN VALUES
99526c24c9SschwarzeIf the allocation fails,
100526c24c9Sschwarze.Fn DH_new
101526c24c9Sschwarzereturns
102526c24c9Sschwarze.Dv NULL
103526c24c9Sschwarzeand sets an error code that can be obtained by
104526c24c9Sschwarze.Xr ERR_get_error 3 .
105526c24c9SschwarzeOtherwise it returns a pointer to the newly allocated structure.
106b2df81b8Sschwarze.Pp
107b2df81b8Sschwarze.Fn DH_up_ref
108b2df81b8Sschwarzereturns 1 for success or 0 for failure.
109526c24c9Sschwarze.Sh SEE ALSO
1107e67b9f1Sschwarze.Xr BN_new 3 ,
11100d4e240Sschwarze.Xr crypto 3 ,
1127e67b9f1Sschwarze.Xr d2i_DHparams 3 ,
113526c24c9Sschwarze.Xr DH_generate_key 3 ,
114526c24c9Sschwarze.Xr DH_generate_parameters 3 ,
1156f64bd5eSschwarze.Xr DH_get0_pqg 3 ,
1167e67b9f1Sschwarze.Xr DH_get_ex_new_index 3 ,
117*dd550453Sschwarze.Xr DH_security_bits 3 ,
1187e67b9f1Sschwarze.Xr DH_set_method 3 ,
1197e67b9f1Sschwarze.Xr DH_size 3 ,
1207e67b9f1Sschwarze.Xr DHparams_print 3 ,
1217e67b9f1Sschwarze.Xr DSA_dup_DH 3 ,
122c4c55c71Sschwarze.Xr EVP_PKEY_CTX_set_dh_paramgen_prime_len 3 ,
1236f64bd5eSschwarze.Xr EVP_PKEY_set1_DH 3
124526c24c9Sschwarze.Sh HISTORY
125526c24c9Sschwarze.Fn DH_new
126526c24c9Sschwarzeand
127526c24c9Sschwarze.Fn DH_free
12810e00d17Sschwarzefirst appeared in SSLeay 0.5.1 and have been available since
1295eb75acbSschwarze.Ox 2.4 .
130b2df81b8Sschwarze.Pp
131b2df81b8Sschwarze.Fn DH_up_ref
132b2df81b8Sschwarzefirst appeared in OpenSSL 0.9.7 and has been available since
133b2df81b8Sschwarze.Ox 3.2 .
134