[tor-commits] [tor/maint-0.3.5] Fix Keccak undefined behavior on exotic platforms.

dgoulet at torproject.org dgoulet at torproject.org
Thu Jan 28 17:37:33 UTC 2021


commit d89974c5c6bdb9083693638014106a41cb6d022d
Author: George Kadianakis <desnacked at riseup.net>
Date:   Thu Dec 17 13:49:17 2020 +0200

    Fix Keccak undefined behavior on exotic platforms.
    
    Bug reported and diagnosed in:
        https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=975977
    
    Fixes bug #40210.
---
 changes/bug40210                  | 5 +++++
 src/ext/keccak-tiny/keccak-tiny.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/changes/bug40210 b/changes/bug40210
new file mode 100644
index 0000000000..f492262a11
--- /dev/null
+++ b/changes/bug40210
@@ -0,0 +1,5 @@
+  o Minor features (crypto):
+    - Fix undefined behavior on our Keccak library. The bug only appears on
+      platforms with 32-byte CPU cache lines (e.g. armv5tel) and would result
+      in wrong digests. Fixes bug 40210; bugfix on 0.2.8.1-alpha. Thanks to
+      Bernhard Ãœbelacker, Arnd Bergmann and weasel for diagnosing this.
diff --git a/src/ext/keccak-tiny/keccak-tiny.h b/src/ext/keccak-tiny/keccak-tiny.h
index a9c8ed6420..dd26386a9a 100644
--- a/src/ext/keccak-tiny/keccak-tiny.h
+++ b/src/ext/keccak-tiny/keccak-tiny.h
@@ -21,7 +21,7 @@ typedef struct keccak_state {
   size_t offset;
 
   uint8_t finalized : 1;
-} keccak_state;
+} __attribute__((aligned(8))) keccak_state;
 
 /* Initialize a Keccak instance suitable for SHA-3 hash functions. */
 int keccak_digest_init(keccak_state *s, size_t bits);





More information about the tor-commits mailing list