Cleanup for cryptographic algorithms vs. compiler optimizations
des at des.no
Sun Jun 13 08:09:27 UTC 2010
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
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
Dag-Erling Smørgrav - des at des.no
More information about the freebsd-current