portable method to zeroize memory when destroying a mpz number

Marc Glisse marc.glisse at inria.fr
Thu Mar 20 14:30:13 UTC 2014

On Thu, 20 Mar 2014, Vicente Benjumea wrote:

> when implementing public key cryptography algorithms, it would be nice
> to have a portable method to zeroize (reset to zero) the memory that
> holds the big-number bits before being destroyed, specially for private
> keys.

I think there have been discussions about this on this list in the past.

> For example, something similar to:
> void
> mpz_clear_zeroize (mpz_ptr m)

That doesn't cover all deallocations. When you write:
GMP may reallocate a so the result fits.

Best would be for you to use the existing GMP interfaces to replace the 
allocation/deallocation functions and zero memory there.

Marc Glisse

More information about the gmp-discuss mailing list