diff options
| -rw-r--r-- | meta-oe/recipes-crypto/botan/botan/0001-Add-more-value-barriers-to-avoid-compiler-induced-si.patch | 67 | ||||
| -rw-r--r-- | meta-oe/recipes-crypto/botan/botan_2.19.1.bb | 1 |
2 files changed, 68 insertions, 0 deletions
diff --git a/meta-oe/recipes-crypto/botan/botan/0001-Add-more-value-barriers-to-avoid-compiler-induced-si.patch b/meta-oe/recipes-crypto/botan/botan/0001-Add-more-value-barriers-to-avoid-compiler-induced-si.patch new file mode 100644 index 0000000000..caf21f0bd3 --- /dev/null +++ b/meta-oe/recipes-crypto/botan/botan/0001-Add-more-value-barriers-to-avoid-compiler-induced-si.patch | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | From 932feeb38783b539ee49e7ba3c1729830984f019 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Jack Lloyd <jack@randombit.net> | ||
| 3 | Date: Sat, 19 Oct 2024 07:43:18 -0400 | ||
| 4 | Subject: [PATCH] Add more value barriers to avoid compiler induced side | ||
| 5 | channels | ||
| 6 | |||
| 7 | The paper https://arxiv.org/pdf/2410.13489 claims that on specific | ||
| 8 | architectures Clang and GCC may introduce jumps here. The donna128 | ||
| 9 | issues only affect 32-bit processors, which explains why we would not | ||
| 10 | see it in the x86-64 valgrind runs. | ||
| 11 | |||
| 12 | The GHASH leak would seem to be generic but the authors only observed | ||
| 13 | it on RISC-V. | ||
| 14 | |||
| 15 | CVE: CVE-2024-50382 | ||
| 16 | CVE: CVE-2024-50383 | ||
| 17 | Upstream-Status: Backport [https://github.com/randombit/botan/commit/53b0cfde580e86b03d0d27a488b6c134f662e957] | ||
| 18 | |||
| 19 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 20 | --- | ||
| 21 | src/lib/utils/donna128.h | 5 +++-- | ||
| 22 | src/lib/utils/ghash/ghash.cpp | 2 +- | ||
| 23 | 2 files changed, 4 insertions(+), 3 deletions(-) | ||
| 24 | |||
| 25 | diff --git a/src/lib/utils/donna128.h b/src/lib/utils/donna128.h | ||
| 26 | index ff57190..dbf2f38 100644 | ||
| 27 | --- a/src/lib/utils/donna128.h | ||
| 28 | +++ b/src/lib/utils/donna128.h | ||
| 29 | @@ -8,6 +8,7 @@ | ||
| 30 | #ifndef BOTAN_CURVE25519_DONNA128_H_ | ||
| 31 | #define BOTAN_CURVE25519_DONNA128_H_ | ||
| 32 | |||
| 33 | +#include <botan/internal/ct_utils.h> | ||
| 34 | #include <botan/mul128.h> | ||
| 35 | |||
| 36 | namespace Botan { | ||
| 37 | @@ -61,7 +62,7 @@ class donna128 final | ||
| 38 | l += x.l; | ||
| 39 | h += x.h; | ||
| 40 | |||
| 41 | - const uint64_t carry = (l < x.l); | ||
| 42 | + const uint64_t carry = CT::Mask<uint64_t>::is_lt(l, x.l).if_set_return(1);; | ||
| 43 | h += carry; | ||
| 44 | return *this; | ||
| 45 | } | ||
| 46 | @@ -69,7 +70,7 @@ class donna128 final | ||
| 47 | donna128& operator+=(uint64_t x) | ||
| 48 | { | ||
| 49 | l += x; | ||
| 50 | - const uint64_t carry = (l < x); | ||
| 51 | + const uint64_t carry = CT::Mask<uint64_t>::is_lt(l, x).if_set_return(1); | ||
| 52 | h += carry; | ||
| 53 | return *this; | ||
| 54 | } | ||
| 55 | diff --git a/src/lib/utils/ghash/ghash.cpp b/src/lib/utils/ghash/ghash.cpp | ||
| 56 | index e24f5e0..8f0afa7 100644 | ||
| 57 | --- a/src/lib/utils/ghash/ghash.cpp | ||
| 58 | +++ b/src/lib/utils/ghash/ghash.cpp | ||
| 59 | @@ -139,7 +139,7 @@ void GHASH::key_schedule(const uint8_t key[], size_t length) | ||
| 60 | m_HM[4*j+2*i+1] = H1; | ||
| 61 | |||
| 62 | // GCM's bit ops are reversed so we carry out of the bottom | ||
| 63 | - const uint64_t carry = R * (H1 & 1); | ||
| 64 | + const uint64_t carry = CT::Mask<uint64_t>::expand(H1 & 1).if_set_return(R); | ||
| 65 | H1 = (H1 >> 1) | (H0 << 63); | ||
| 66 | H0 = (H0 >> 1) ^ carry; | ||
| 67 | } | ||
diff --git a/meta-oe/recipes-crypto/botan/botan_2.19.1.bb b/meta-oe/recipes-crypto/botan/botan_2.19.1.bb index 71e805b655..a961bc775f 100644 --- a/meta-oe/recipes-crypto/botan/botan_2.19.1.bb +++ b/meta-oe/recipes-crypto/botan/botan_2.19.1.bb | |||
| @@ -10,6 +10,7 @@ SRC_URI = "https://botan.randombit.net/releases/Botan-${PV}.tar.xz \ | |||
| 10 | file://0003-FIX-missing-validation-of-authority-of-delegation-re.patch \ | 10 | file://0003-FIX-missing-validation-of-authority-of-delegation-re.patch \ |
| 11 | file://0004-review-comments.patch \ | 11 | file://0004-review-comments.patch \ |
| 12 | file://0001-Address-various-name-constraint-bugs.patch \ | 12 | file://0001-Address-various-name-constraint-bugs.patch \ |
| 13 | file://0001-Add-more-value-barriers-to-avoid-compiler-induced-si.patch \ | ||
| 13 | " | 14 | " |
| 14 | SRC_URI[sha256sum] = "e26e00cfefda64082afdd540d3c537924f645d6a674afed2cd171005deff5560" | 15 | SRC_URI[sha256sum] = "e26e00cfefda64082afdd540d3c537924f645d6a674afed2cd171005deff5560" |
| 15 | 16 | ||
