]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sha1: properly wipe variables
authorThomas Weißschuh <thomas@t-8ch.de>
Sun, 24 Dec 2023 12:50:40 +0000 (13:50 +0100)
committerThomas Weißschuh <thomas@t-8ch.de>
Sun, 31 Dec 2023 12:06:02 +0000 (13:06 +0100)
Dead stores may very well be optimized away.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
lib/sha1.c

index eedeaa84aea89a86d0bfd2a5fe51914be965ad69..2e6b44d05309e1d1f3316399764aebc5aba0ded6 100644 (file)
@@ -153,7 +153,11 @@ void ul_SHA1Transform(uint32_t state[5], const unsigned char buffer[64])
        state[3] += d;
        state[4] += e;
        /* Wipe variables */
-       a = b = c = d = e = 0;
+       explicit_bzero(&a, sizeof(a));
+       explicit_bzero(&b, sizeof(b));
+       explicit_bzero(&c, sizeof(c));
+       explicit_bzero(&d, sizeof(d));
+       explicit_bzero(&e, sizeof(e));
 #ifdef UL_SHA1HANDSOFF
        memset(block, '\0', sizeof(block));
 #endif