BN_bn2binpad

Encode a BIGNUM as a fixed-length big-endian unsigned byte string.

Synopsis

Declared in <openssl/bn.h>

int
BN_bn2binpad(
    BIGNUM const* a,
    unsigned char* to,
    int tolen);

Return Value

tolen on success, or -1 if a does not fit in tolen bytes.

Parameters

NameDescription
aValue to encode (absolute value; sign is ignored).
toDestination buffer of tolen bytes; leading zeros are written as needed.
tolenExact output length in bytes.