Closed lhf closed 6 years ago
One may call mp_int_unsigned_len(&z)
to get the length of the buffer consumed, e.g.,
mp_result len = mp_int_unsigned_len(&z);
unsigned char *buf = malloc(len);
mp_int_to_unsigned(&z, buf, len);
I realize that's an extra call, but it's not a very expensive one, so I'd rather not change the API for this.
I misread the docs. Sorry for the noise.
mp_int_to_unsigned
does not return the number of bytes actually written to the buffer.mp_int_to_unsigned
callss_tobin
, which does return the number of bytes actually written to the buffer, so the information is available.One solution is to change
mp_int_to_unsigned
tobut it is a breaking change.