Cleanup for cryptographic algorithms vs. compiler optimizations

From: Ulrich Spörlein <uqs_at_spoerlein.net>
Date: Fri, 11 Jun 2010 18:21:18 +0200
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
Received on Fri Jun 11 2010 - 14:21:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:04 UTC