xref: /openbsd-src/lib/libcrypto/man/BN_CTX_new.3 (revision 58fbf5d6aa35e3d66f2c32c61d2f38824a990e85)
1.\"	$OpenBSD: BN_CTX_new.3,v 1.9 2019/06/10 14:58:48 schwarze Exp $
2.\"	OpenSSL aafbe1cc Jun 12 23:42:08 2013 +0100
3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org>.
5.\" Copyright (c) 2000, 2013 The OpenSSL Project.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in
16.\"    the documentation and/or other materials provided with the
17.\"    distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\"    software must display the following acknowledgment:
21.\"    "This product includes software developed by the OpenSSL Project
22.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\"    endorse or promote products derived from this software without
26.\"    prior written permission. For written permission, please contact
27.\"    openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\"    nor may "OpenSSL" appear in their names without prior written
31.\"    permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\"    acknowledgment:
35.\"    "This product includes software developed by the OpenSSL Project
36.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: June 10 2019 $
52.Dt BN_CTX_NEW 3
53.Os
54.Sh NAME
55.Nm BN_CTX_new ,
56.Nm BN_CTX_free ,
57.Nm BN_CTX_init
58.Nd allocate and free BN_CTX structures
59.Sh SYNOPSIS
60.In openssl/bn.h
61.Ft BN_CTX *
62.Fo BN_CTX_new
63.Fa void
64.Fc
65.Ft void
66.Fo BN_CTX_free
67.Fa "BN_CTX *c"
68.Fc
69.Pp
70Deprecated:
71.Pp
72.Ft void
73.Fo BN_CTX_init
74.Fa "BN_CTX *c"
75.Fc
76.Sh DESCRIPTION
77A
78.Vt BN_CTX
79is a structure that holds
80.Vt BIGNUM
81temporary variables used by library functions.
82Since dynamic memory allocation to create
83.Vt BIGNUM Ns s
84is rather expensive when used in conjunction with repeated subroutine
85calls, the
86.Vt BN_CTX
87structure is used.
88.Pp
89.Fn BN_CTX_new
90allocates and initializes a
91.Vt BN_CTX
92structure.
93.Pp
94.Fn BN_CTX_free
95frees the components of the
96.Vt BN_CTX
97and, if it was created by
98.Fn BN_CTX_new ,
99also the structure itself.
100If
101.Xr BN_CTX_start 3
102has been used on the
103.Vt BN_CTX ,
104.Xr BN_CTX_end 3
105must be called before the
106.Vt BN_CTX
107may be freed by
108.Fn BN_CTX_free .
109If
110.Fa c
111is a
112.Dv NULL
113pointer, no action occurs.
114.Pp
115.Fn BN_CTX_init
116(deprecated) initializes an existing uninitialized
117.Vt BN_CTX .
118This should not be used for new programs.
119Use
120.Fn BN_CTX_new
121instead.
122.Sh RETURN VALUES
123.Fn BN_CTX_new
124returns a pointer to the
125.Vt BN_CTX .
126If the allocation fails, it returns
127.Dv NULL
128and sets an error code that can be obtained by
129.Xr ERR_get_error 3 .
130.Sh SEE ALSO
131.Xr BN_add 3 ,
132.Xr BN_CTX_start 3 ,
133.Xr BN_new 3
134.Sh HISTORY
135.Fn BN_CTX_new
136and
137.Fn BN_CTX_free
138first appeared in SSLeay 0.5.1 and have been available since
139.Ox 2.4 .
140.Pp
141.Fn BN_CTX_init
142first appeared in SSLeay 0.9.1 and has been available since
143.Ox 2.6 .
144