Cleanup for cryptographic algorithms vs. compiler optimizations

Ulrich Spörlein uqs at
Fri Jun 11 16:21:20 UTC 2010


optimizing compilers have a tendency to remove assignments that have no
side effects. The code in sys/crypto/sha2/sha2.c is doing a lot of
zeroing variables, which is however optimized away. I haven't looked
close enough to see if all these vars happen to fit into the registers,
but a nice overview can be had here:

Compiling the code with/without those assignment results in the same
object code. Is there a canonical way to zero those variables and should
we use them (memset perhaps? what are the performance implications?)


More information about the freebsd-current mailing list