xref: /onnv-gate/usr/src/common/openssl/doc/crypto/BN_CTX_start.pod (revision 2175:b0b2f052a486)
1*2175Sjp161948=pod
2*2175Sjp161948
3*2175Sjp161948=head1 NAME
4*2175Sjp161948
5*2175Sjp161948BN_CTX_start, BN_CTX_get, BN_CTX_end - use temporary BIGNUM variables
6*2175Sjp161948
7*2175Sjp161948=head1 SYNOPSIS
8*2175Sjp161948
9*2175Sjp161948 #include <openssl/bn.h>
10*2175Sjp161948
11*2175Sjp161948 void BN_CTX_start(BN_CTX *ctx);
12*2175Sjp161948
13*2175Sjp161948 BIGNUM *BN_CTX_get(BN_CTX *ctx);
14*2175Sjp161948
15*2175Sjp161948 void BN_CTX_end(BN_CTX *ctx);
16*2175Sjp161948
17*2175Sjp161948=head1 DESCRIPTION
18*2175Sjp161948
19*2175Sjp161948These functions are used to obtain temporary B<BIGNUM> variables from
20*2175Sjp161948a B<BN_CTX> (which can been created by using L<BN_CTX_new(3)|BN_CTX_new(3)>)
21*2175Sjp161948in order to save the overhead of repeatedly creating and
22*2175Sjp161948freeing B<BIGNUM>s in functions that are called from inside a loop.
23*2175Sjp161948
24*2175Sjp161948A function must call BN_CTX_start() first. Then, BN_CTX_get() may be
25*2175Sjp161948called repeatedly to obtain temporary B<BIGNUM>s. All BN_CTX_get()
26*2175Sjp161948calls must be made before calling any other functions that use the
27*2175Sjp161948B<ctx> as an argument.
28*2175Sjp161948
29*2175Sjp161948Finally, BN_CTX_end() must be called before returning from the function.
30*2175Sjp161948When BN_CTX_end() is called, the B<BIGNUM> pointers obtained from
31*2175Sjp161948BN_CTX_get() become invalid.
32*2175Sjp161948
33*2175Sjp161948=head1 RETURN VALUES
34*2175Sjp161948
35*2175Sjp161948BN_CTX_start() and BN_CTX_end() return no values.
36*2175Sjp161948
37*2175Sjp161948BN_CTX_get() returns a pointer to the B<BIGNUM>, or B<NULL> on error.
38*2175Sjp161948Once BN_CTX_get() has failed, the subsequent calls will return B<NULL>
39*2175Sjp161948as well, so it is sufficient to check the return value of the last
40*2175Sjp161948BN_CTX_get() call. In case of an error, an error code is set, which
41*2175Sjp161948can be obtained by L<ERR_get_error(3)|ERR_get_error(3)>.
42*2175Sjp161948
43*2175Sjp161948
44*2175Sjp161948=head1 SEE ALSO
45*2175Sjp161948
46*2175Sjp161948L<BN_CTX_new(3)|BN_CTX_new(3)>
47*2175Sjp161948
48*2175Sjp161948=head1 HISTORY
49*2175Sjp161948
50*2175Sjp161948BN_CTX_start(), BN_CTX_get() and BN_CTX_end() were added in OpenSSL 0.9.5.
51*2175Sjp161948
52*2175Sjp161948=cut
53