Skip to content

Commit

Permalink
CI fix
Browse files Browse the repository at this point in the history
Fix carry and borrow calculations in curve448_gf.cpp + header
  • Loading branch information
FAlbertDev committed Mar 8, 2024
1 parent 1069bdc commit f317a74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/pubkey/curve448/curve448_utils/curve448_gf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>(sum < *carry);
*carry = carry_a_plus_b + static_cast<uint64_t>(sum < *carry);
return sum;
}

Expand All @@ -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<uint64_t>(z > diff);
*borrow = borrow_a_min_b + static_cast<uint64_t>(z > diff);
return z;
}

Expand Down Expand Up @@ -170,8 +170,9 @@ void word_arr_to_span64(std::span<uint64_t, S> out, std::span<const word, S * wo

void gf_mul(std::span<uint64_t, 7> out, std::span<const uint64_t, 7> a, std::span<const uint64_t, 7> b) {
std::array<uint64_t, 14> ws;
if constexpr(sizeof(word) == sizeof(uint64_t)) {
bigint_comba_mul7(ws.data(), a.data(), b.data());
if constexpr(std::same_as<uint64_t, word>) {
bigint_comba_mul7(
static_cast<word*>(ws.data()), static_cast<const word*>(a.data()), static_cast<const word*>(b.data()));
} else {
const auto a_arr = load_le<std::array<uint64_t, 7>>(store_le(a));
const auto b_arr = load_le<std::array<uint64_t, 7>>(store_le(b));
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pubkey/ed448/ed448.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include <botan/pk_keys.h>

#include <array>

namespace Botan {

/**
Expand Down

0 comments on commit f317a74

Please sign in to comment.