Cleanup for cryptographic algorithms vs. compiler optimizations
Ulrich Spörlein
uqs at spoerlein.net
Fri Jun 11 16:21:20 UTC 2010
Hello,
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:
https://www.spoerlein.net/scan-build/freebsd-head/sbin.gbde/2010-06-05-1/
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?)
Regards,
Uli
More information about the freebsd-current
mailing list