Hi Gabriel,
This is no bug. In your code, you should check the return value of
BN_bn2bin and you will notice that it returns zero. This means that
nothing has been written to your "bytes" buffer. So, your code is just
printing garbage. In your example, you are dealing with the zero value,
and in openSSL, BN_num_bytes returns 0 in this case (it's deduced from
BN_num_bits).

Cheers,

Mounir IDRASSI
IDRIX
http://www.idrix.fr

Gabriel Maganis wrote:
> Hello,
>    I am new to openssl and I have tried to use the bignumber library
> like below,
>
> ------------------
>  unsigned char* hex = "000000000000000000000000000000";
>  BIGNUM* bn;
>  unsigned char* bytes;
>  int i;
>  bn = BN_new();
>
>  BN_hex2bn(&bn, hex);
>
>  bytes = (unsigned char*) malloc(16);
>  BN_bn2bin(bn, bytes);
>
>   for(i=0; i<16; i++)
>         printf("%02x", bytes[i]);
> -----------------
>
> I believe I have found a bug because the above should print 32 '0'
> characters but it doesn't. I also found that the code above works for
> other hexadecimal strings and it's only for the above case that it
> fails.
>
> Thanks.
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> Development Mailing List                       openssl-dev@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]
>
>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to