---
name: "libressl-BN_CTX_new"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-BN_CTX_new"
---

# libressl-BN\_CTX\_new(3)

allocate and free BN\_CTX structures

## NAME

**BN\_CTX\_new**, **BN\_CTX\_free** – allocate and free BN\_CTX structures

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/bn.h\>**

*BN\_CTX* *\**\

**BN\_CTX\_new**(*void*);

*void*\

**BN\_CTX\_free**(*BN\_CTX \*c*);

## DESCRIPTION

A *BN\_CTX* is a structure that holds *BIGNUM* temporary variables used by library functions. Since dynamic memory allocation to create *BIGNUM*s is rather expensive when used in conjunction with repeated subroutine calls, the *BN\_CTX* structure is used.

**BN\_CTX\_new**() allocates and initializes a *BN\_CTX* structure.

**BN\_CTX\_free**() frees the components of the *BN\_CTX* and, if it was created by **BN\_CTX\_new**(), also the structure itself. If BN\_CTX\_start(3) has been used on the *BN\_CTX*, BN\_CTX\_end(3) must be called before the *BN\_CTX* may be freed by **BN\_CTX\_free**(). If *c* is a NULL pointer, no action occurs.

## RETURN VALUES

**BN\_CTX\_new**() returns a pointer to the *BN\_CTX*. If the allocation fails, it returns NULL and sets an error code that can be obtained by ERR\_get\_error(3).

## SEE ALSO

BN\_add(3), BN\_CTX\_start(3), BN\_new(3)

## HISTORY

**BN\_CTX\_new**() and **BN\_CTX\_free**() first appeared in SSLeay 0.5.1 and have been available since OpenBSD 2.4.
