OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: crypto_memset (was: Re: Zero it if you're going to copy it out.)

From: Jean-Yves Migeon (jeanyves.migeonfree.fr)
Date: Sun Jul 22 2012 - 11:17:04 CDT


On 22.07.2012 18:01, Alan Barrett wrote:
> I have an implementation of memset_s. It's fairly intrusive, in that
> several header files need extra declarations for strange types, and I
> haven't implemented the constraint handler callbacks.

Strange types?

> It's easy to usae volatile pointers to define functions that will not be
> optinmised away. For example (from a message I sent in Febroary 2012):
>
> /*
> * memset_volatile is a volatile pointer to the memset function.
> * You can call (*memset_volatile)(buf, val, len) or even
> * memset_volatile(buf, val, len) just as you would call
> * memset(buf, val, len), but the use of a volatile pointer
> * guarantees that the compiler will not optimise the call away.
> */
> void * (* volatile memset_volatile)(void *, int, size_t) = memset;
>
> I think I like "explicit_memset" better than "memset_volatile" as the
> function name.

Describes function's usage better, yes.

--
Jean-Yves Migeon
jeanyves.migeonfree.fr