pretty-print a BIGNUM object
const char *label, const BIGNUM
*bn, unsigned char *buffer, int
prints bn to bio_out in
human-readable form. Despite its name and the header file, this function has
nothing to do with ASN.1.
The caller is responsible for providing a
buffer that is at least
+ 1 bytes long. To avoid a buffer overrun, be careful to not forget the
“plus one”. It is unspecified what the buffer may contain
after the function returns.
If indent is greater than zero, indent space characters are printed first, but not more than 128.
The NUL-terminated label is printed next.
After that, there are three cases:
- If bn represents the number zero, "0" is printed.
- If bn can be represented by the data type unsigned long, it is printed in decimal notation, followed by hexadecimal notation in parentheses, both optionally preceded by a minus sign.
- Otherwise, the string "(Negative)" is printed if appropriate, a new output line is started, and the indentation is increased by four space characters. The bytes of the value of bn are then printed in big-endian order, each byte represented by a two-digit hexadecimal number, and each but the last byte followed by a colon. A new output line is started after every group of 15 bytes.
Finally, a newline character is printed to end the output.
If bn is a
pointer, all arguments are ignored and nothing is printed.
ASN1_bn_print() returns 1 if successful or
if bn is a
NULL pointer. It
returns 0 if printing fails.
ASN1_buf_print(3), BIO_new(3), BIO_write(3), BN_is_negative(3), BN_is_zero(3), BN_new(3), BN_num_bytes(3), BN_print(3)
ASN1_bn_print() first appeared in OpenSSL
1.0.0 and has been available since OpenBSD 4.9.