xref: /openbsd/lib/libcrypto/man/BN_new.3 (revision 5af055cd)
1.Dd $Mdocdate: February 23 2015 $
2.Dt BN_NEW 3
3.Os
4.Sh NAME
5.Nm BN_new ,
6.Nm BN_init ,
7.Nm BN_clear ,
8.Nm BN_free ,
9.Nm BN_clear_free
10.Nd allocate and free BIGNUMs
11.Sh SYNOPSIS
12.In openssl/bn.h
13.Ft BIGNUM *
14.Fo BN_new
15.Fa void
16.Fc
17.Ft void
18.Fo BN_init
19.Fa "BIGNUM *"
20.Fc
21.Ft void
22.Fo BN_clear
23.Fa "BIGNUM *a"
24.Fc
25.Ft void
26.Fo BN_free
27.Fa "BIGNUM *a"
28.Fc
29.Ft void
30.Fo BN_clear_free
31.Fa "BIGNUM *a"
32.Fc
33.Sh DESCRIPTION
34.Fn BN_new
35allocates and initializes a
36.Vt BIGNUM
37structure.
38.Fn BN_init
39initializes an existing uninitialized
40.Vt BIGNUM .
41.Pp
42.Fn BN_clear
43is used to destroy sensitive data such as keys when they are no longer
44needed.
45It erases the memory used by
46.Fa a
47and sets it to the value 0.
48.Pp
49.Fn BN_free
50frees the components of the
51.Vt BIGNUM ,
52and if it was created by
53.Fn BN_new ,
54also the structure itself.
55.Fn BN_clear_free
56additionally overwrites the data before the memory is returned to the
57system.
58.Sh RETURN VALUES
59.Fn BN_new
60returns a pointer to the
61.Vt BIGNUM .
62If the allocation fails, it returns
63.Dv NULL
64and sets an error code that can be obtained by
65.Xr ERR_get_error 3 .
66.Pp
67.Fn BN_init ,
68.Fn BN_clear ,
69.Fn BN_free ,
70and
71.Fn BN_clear_free
72return no values.
73.Sh SEE ALSO
74.Xr bn 3 ,
75.Xr ERR_get_error 3
76.Sh HISTORY
77.Fn BN_new ,
78.Fn BN_clear ,
79.Fn BN_free ,
80and
81.Fn BN_clear_free
82are available in all versions on SSLeay and OpenSSL.
83.Fn BN_init
84was added in SSLeay 0.9.1b.
85