— allocate and free
The BN library performs arithmetic operations on integers of arbitrary size. It was written for use in public key cryptography, such as RSA and Diffie-Hellman.
It uses dynamic memory allocation for storing its data structures. That means that there is no limit on the size of the numbers manipulated by these functions, but return values must always be checked in case a memory allocation error has occurred.
The basic object in this library is a BIGNUM. It is used to hold a single large integer. This type should be considered opaque and fields should not be modified or accessed directly.
allocates and initializes a BIGNUM structure, in
particular setting the value to zero and the flags to
BN_FLG_MALLOCED. The security-relevant flag
BN_FLG_CONSTTIME is not set by default.
is used to destroy sensitive data such as keys when they are no longer
needed. It erases the memory used by a and sets it to
the value 0.
frees the components of the BIGNUM and, if it was
BN_new(), also the structure itself.
additionally overwrites the data before the memory is returned to the
system. If a is a
pointer, no action occurs.
BN_new() returns a pointer to the
BIGNUM. If the allocation fails, it returns
NULL and sets an error code that can be obtained by
ASN1_bn_print(3), BN_add(3), BN_add_word(3), BN_BLINDING_new(3), BN_bn2bin(3), BN_cmp(3), BN_copy(3), BN_CTX_new(3), BN_CTX_start(3), BN_generate_prime(3), BN_kronecker(3), BN_mod_inverse(3), BN_mod_mul_montgomery(3), BN_mod_sqrt(3), BN_num_bytes(3), BN_rand(3), BN_security_bits(3), BN_set_bit(3), BN_set_flags(3), BN_set_negative(3), BN_swap(3), BN_zero(3), crypto(3), get_rfc3526_prime_8192(3)
BN_clear_free() first appeared in SSLeay 0.5.1 and
have been available since OpenBSD 2.4.