Re: Cleanup for cryptographic algorithms vs. compiler optimizations

From: Dag-Erling Smørgrav <des_at_des.no>
Date: Sun, 13 Jun 2010 10:07:15 +0200
Bernd Walter <ticso_at_cicely7.cicely.de> writes:
> Dag-Erling Smørgrav <des_at_des.no> writes:
> > Bernd Walter <ticso_at_cicely7.cicely.de> writes:
> > > I'm not sure when removing a memset is allowed.
> > Always, if the compiler can determine that the data will not be used
> > later.
> I'm at least sure that the compiler can't if it is linked from another
> object file.

When running in hosted mode, the compiler can *always* inline a memset()
call or eliminate it if it can determine that the result is not used.

> The problem with memset is that the compiler has an internal
> implementation.

That's a feature, not a problem.

> On the other hand I wonder what the deep sense is to clear memory
> which is unused later.  I know that crypto code can be tricky
> sometimes, but if someone is willing to explain the specific reason my
> curiosity would be satified.

You always overwrite passphrases, keys etc. as soon as you're done with
them so they don't end up in a crash dump or on a swap disk or
something.

DES
-- 
Dag-Erling Smørgrav - des_at_des.no
Received on Sun Jun 13 2010 - 06:09:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:04 UTC