[Cryptography] How to lock registers with GCC?

tpb-crypto at laposte.net tpb-crypto at laposte.net
Thu May 8 19:56:40 EDT 2014


People,


I've been tinkering a while with GCC while trying to follow programming best practices for security, as some of you guys advocate.

While making an encryption routine I stumbled upon the possibility of using a register to keep the key, while erasing it from memory.

By using assembly it is possible to keep that register unchanged and use others to do stuff. That would make easy to build routines, if not by the bare metal programming part, lol.

But it becomes quite complicated to try write more useful programs, because you know, assembly.

Finally, my question is:

Is it possible to give a directive to GCC while compiling and/or does it support some macro/routine/directive/library/whatever, that would allow to load values into processor registers and then lock one or two registers, which would become unchangeable? Performance notwithstanding.

I know methods like using certain Intel Nehalem's registers that are normally not used (debug registers) for storing stuff, but that is too specific for that family of processors. How about something that is at least cross-processor-families, if not cross-platform?

Does something like that exists and/or is it possible to build it?


More information about the cryptography mailing list