Creating mpz_t from binary data

Saju Pillai saju.pillai at gmail.com
Wed Mar 17 16:22:06 CET 2010


Hello,

  I am new to GMP. I receive a multi precision big endian integer 
represented in two's complement. I am on a little endian machine. How 
can I create a mpz_t using this data ?

Will reversing the data bytes to create a little endian representation 
and calling mpz_set_str(rop, data, 2) work ?. Since this is binary data, 
  NULs may occur anywhere in the data. How do you suggest I proceed ?

The mpint data type described at 
http://tools.ietf.org/html/rfc4251#section-5 (SSH architecture rfc) is 
the data format I am dealing with.

-srp






More information about the gmp-discuss mailing list