
#use wml::openssl-macros area=docs page=BN_CTX_new

<title>Documents, BN_CTX_new(3)</title>

<h1>BN_CTX_new(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
	<LI><A HREF="#SEE_ALSO">SEE ALSO</A>
	<LI><A HREF="#HISTORY">HISTORY</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
BN_CTX_new, BN_CTX_init, BN_CTX_free - allocate and free BN_CTX structures

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/bn.h&gt;
</PRE>
<PRE> BN_CTX *BN_CTX_new(void);
</PRE>
<PRE> void BN_CTX_init(BN_CTX *c);
</PRE>
<PRE> void BN_CTX_free(BN_CTX *c);
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
A <STRONG>BN_CTX</STRONG> is a structure that holds <STRONG>BIGNUM</STRONG> temporary variables used by library functions. Since dynamic memory
allocation to create <STRONG>BIGNUM</STRONG>s is rather expensive when used in conjunction with repeated subroutine
calls, the <STRONG>BN_CTX</STRONG> structure is used.

</P>
<P>
<CODE>BN_CTX_new()</CODE> allocates and initializes a <STRONG>BN_CTX</STRONG>
structure. <CODE>BN_CTX_init()</CODE> initializes an existing uninitialized
<STRONG>BN_CTX</STRONG>.

</P>
<P>
<CODE>BN_CTX_free()</CODE> frees the components of the <STRONG>BN_CTX</STRONG>, and if it was created by <CODE>BN_CTX_new(),</CODE> also the structure
itself. If <A HREF="../crypto/BN_CTX_start.html#">BN_CTX_start(3)</A> has been used on the <STRONG>BN_CTX</STRONG>,
<A HREF="../crypto/BN_CTX_start.html#">BN_CTX_end(3)</A> must be called before the <STRONG>BN_CTX</STRONG>
may be freed by <CODE>BN_CTX_free().</CODE>

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
<CODE>BN_CTX_new()</CODE> returns a pointer to the <STRONG>BN_CTX</STRONG>. If the allocation fails, it returns <STRONG>NULL</STRONG> and sets an error code that can be obtained by
<A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>.

</P>
<P>
<CODE>BN_CTX_init()</CODE> and <CODE>BN_CTX_free()</CODE> have no return
values.

</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
<A HREF="../crypto/bn.html#">bn(3)</A>, <A HREF="../crypto/ERR_get_error.html#">ERR_get_error(3)</A>, <A HREF="../crypto/BN_add.html#">BN_add(3)</A>,
<A HREF="../crypto/BN_CTX_start.html#">BN_CTX_start(3)</A>



</P>
<P>
<HR>
<H1><A NAME="HISTORY">HISTORY</A></H1>
<P>
<CODE>BN_CTX_new()</CODE> and <CODE>BN_CTX_free()</CODE> are available in
all versions on SSLeay and OpenSSL. <CODE>BN_CTX_init()</CODE> was added in
SSLeay 0.9.1b.

</P>
:}

