xref: /openbsd-src/lib/libcrypto/man/BN_CTX_new.3 (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1.Dd $Mdocdate: February 23 2015 $
2.Dt BN_CTX_NEW 3
3.Os
4.Sh NAME
5.Nm BN_CTX_new ,
6.Nm BN_CTX_init ,
7.Nm BN_CTX_free
8.Nd allocate and free BN_CTX structures
9.Sh SYNOPSIS
10.In openssl/bn.h
11.Ft BN_CTX *
12.Fo BN_CTX_new
13.Fa void
14.Fc
15.Ft void
16.Fo BN_CTX_free
17.Fa "BN_CTX *c"
18.Fc
19.Pp
20Deprecated:
21.Pp
22.Ft void
23.Fo BN_CTX_init
24.Fa "BN_CTX *c"
25.Fc
26.Sh DESCRIPTION
27A
28.Vt BN_CTX
29is a structure that holds
30.Vt BIGNUM
31temporary variables used by library functions.
32Since dynamic memory allocation to create
33.Vt BIGNUM Ns s
34is rather expensive when used in conjunction with repeated subroutine
35calls, the
36.Vt BN_CTX
37structure is used.
38.Pp
39.Fn BN_CTX_new
40allocates and initializes a
41.Vt BN_CTX
42structure.
43.Pp
44.Fn BN_CTX_free
45frees the components of the
46.Vt BN_CTX ,
47and if it was created by
48.Fn BN_CTX_new ,
49also the structure itself.
50If
51.Xr BN_CTX_start 3
52has been used on the
53.Vt BN_CTX ,
54.Xr BN_CTX_end 3
55must be called before the
56.Vt BN_CTX
57may be freed by
58.Fn BN_CTX_free .
59.Pp
60.Fn BN_CTX_init
61(deprecated) initializes an existing uninitialized
62.Vt BN_CTX .
63This should not be used for new programs.
64Use
65.Fn BN_CTX_new
66instead.
67.Sh RETURN VALUES
68.Fn BN_CTX_new
69returns a pointer to the
70.Vt BN_CTX .
71If the allocation fails, it returns
72.Dv NULL
73and sets an error code that can be obtained by
74.Xr ERR_get_error 3 .
75.Pp
76.Fn BN_CTX_init
77and
78.Fn BN_CTX_free
79return no value.
80.Sh SEE ALSO
81.Xr bn 3 ,
82.Xr BN_add 3 ,
83.Xr BN_CTX_start 3 ,
84.Xr ERR_get_error 3
85.Sh HISTORY
86.Fn BN_CTX_new
87and
88.Fn BN_CTX_free
89are available in all versions on SSLeay and OpenSSL.
90.Fn BN_CTX_init
91was added in SSLeay 0.9.1b.
92