Zero an mpz_t?

Marc Glisse marc.glisse at
Mon Dec 19 11:52:49 CET 2011

On Mon, 19 Dec 2011, James Barlow-Bignell wrote:

> I have requirements to zero cryptographic 'secrets' represented by mpz_t types. I'll have a look through the  internal functions and see if I can access the memory from there.

If you don't want to leave secrets lying around, you probably need to use 
your own allocator (so that realloc and free calls zero the data), so you 
might as well reuse that and just call mpz_clear to erase data. Note that 
gmp may also write quite a bit of data on the stack unless you disable the 
use of alloca.

Marc Glisse

More information about the gmp-discuss mailing list