From f317a74404700aa202d93725895276a767836124 Mon Sep 17 00:00:00 2001 From: Fabian Albert Date: Fri, 8 Mar 2024 09:08:27 +0100 Subject: [PATCH] CI fix Fix carry and borrow calculations in curve448_gf.cpp + header --- src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp | 9 +++++---- src/lib/pubkey/ed448/ed448.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp b/src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp index 78839d2473a..0ef7c7cf9b0 100644 --- a/src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp +++ b/src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp @@ -38,7 +38,7 @@ inline uint64_t u64_add_with_carry(uint64_t a, uint64_t b, bool* carry) { uint64_t sum = a + b; const uint64_t carry_a_plus_b = (sum < a); sum += *carry; - *carry = carry_a_plus_b | static_cast(sum < *carry); + *carry = carry_a_plus_b + static_cast(sum < *carry); return sum; } @@ -52,7 +52,7 @@ inline uint64_t u64_sub_with_borrow(uint64_t a, uint64_t b, bool* borrow) { const word diff = a - b; const word borrow_a_min_b = diff > a; const word z = diff - *borrow; - *borrow = borrow_a_min_b | static_cast(z > diff); + *borrow = borrow_a_min_b + static_cast(z > diff); return z; } @@ -170,8 +170,9 @@ void word_arr_to_span64(std::span out, std::span out, std::span a, std::span b) { std::array ws; - if constexpr(sizeof(word) == sizeof(uint64_t)) { - bigint_comba_mul7(ws.data(), a.data(), b.data()); + if constexpr(std::same_as) { + bigint_comba_mul7( + static_cast(ws.data()), static_cast(a.data()), static_cast(b.data())); } else { const auto a_arr = load_le>(store_le(a)); const auto b_arr = load_le>(store_le(b)); diff --git a/src/lib/pubkey/ed448/ed448.h b/src/lib/pubkey/ed448/ed448.h index de4bfb20d7a..5f2a8920c9f 100644 --- a/src/lib/pubkey/ed448/ed448.h +++ b/src/lib/pubkey/ed448/ed448.h @@ -11,6 +11,8 @@ #include +#include + namespace Botan { /**