pub unsafe extern "C" fn mp_int_to_binary(
z: mp_int,
buf: *mut c_uchar,
limit: c_int,
) -> mp_result
Expand description
Converts z
to 2’s complement binary, writing at most limit
bytes into
the given buf
. Returns MP_TRUNC
if the buffer limit was too small to
contain the whole value. If this occurs, the contents of buf will be
effectively garbage, as the function uses the buffer as scratch space.
The binary representation of z
is in base-256 with digits ordered from
most significant to least significant (network byte ordering). The
high-order bit of the first byte is set for negative values, clear for
non-negative values.
As a result, non-negative values will be padded with a leading zero byte if
the high-order byte of the base-256 magnitude is set. This extra byte is
accounted for by the mp_int_binary_len()
function.