[gnutls-devel] Bug: gnutls_dh_get_group prepends a zero byte to prime

Nikos Mavrogiannopoulos nmav at gnutls.org
Fri May 22 09:05:46 CEST 2015

On Fri, May 22, 2015 at 12:17 AM, Thomas Klute
<thomas2.klute at uni-dortmund.de> wrote:
> Hello,
> I believe I have found a bug in gnutls_dh_get_group: It returns the
> prime with an extra zero byte at the beginning.

Indeed, I see that the number is written as a non-negative integer
there, so it will have a leading zero if the number would have been
interpreted as negative. The intention was to assist applications who
may import that value in an mpz_t value. Would it make sense to
document the fact that there may be a leading zero in that case,
rather than eliminating? That behavior has been for quite some time
and I believe any users of this function would already use or work
around it.


More information about the Gnutls-devel mailing list