8#ifndef BOTAN_CURVE25519_DONNA128_H_
9#define BOTAN_CURVE25519_DONNA128_H_
11#include <botan/internal/ct_utils.h>
12#include <botan/internal/mul128.h>
19 constexpr donna128(uint64_t ll = 0, uint64_t hh = 0) {
32 z.l = z.h >> (shift - 64);
34 }
else if(shift == 64) {
37 }
else if(shift > 0) {
38 const uint64_t
carry = z.h <<
static_cast<size_t>(64 - shift);
51 z.h = z.l << (shift - 64);
53 }
else if(shift == 64) {
56 }
else if(shift > 0) {
57 const uint64_t
carry = z.l >>
static_cast<size_t>(64 - shift);
59 z.h = (z.h << shift) |
carry;
65 constexpr friend uint64_t
operator&(
const donna128& x, uint64_t mask) {
return x.l & mask; }
89 constexpr uint64_t
lo()
const {
return l; }
91 constexpr uint64_t
hi()
const {
return h; }
93 constexpr operator uint64_t()
const {
return l; }
96 uint64_t h = 0, l = 0;
99template <std::
unsigned_
integral T>
101 BOTAN_ARG_CHECK(x.
hi() == 0,
"High 64 bits of donna128 set to zero during multiply");
103 uint64_t lo = 0, hi = 0;
108template <std::
unsigned_
integral T>
134 return (a >> shift).lo();
142#if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
143inline uint64_t
carry_shift(
const uint128_t a,
size_t shift) {
144 return static_cast<uint64_t
>(a >> shift);
147inline uint64_t
combine_lower(
const uint128_t a,
size_t s1,
const uint128_t
b,
size_t s2) {
148 return static_cast<uint64_t
>((a >> s1) | (
b << s2));
#define BOTAN_ARG_CHECK(expr, msg)
static constexpr Mask< T > is_lt(T x, T y)
constexpr uint64_t operator&=(uint64_t mask)
constexpr uint64_t lo() const
constexpr donna128 & operator+=(uint64_t x)
constexpr friend donna128 operator<<(const donna128 &x, T shift)
constexpr friend uint64_t operator&(const donna128 &x, uint64_t mask)
constexpr uint64_t hi() const
constexpr donna128(uint64_t ll=0, uint64_t hh=0)
constexpr friend donna128 operator>>(const donna128 &x, T shift)
constexpr donna128 & operator+=(const donna128 &x)
donna128 & operator=(const donna128 &)=default
donna128(const donna128 &)=default
int(* final)(unsigned char *, CTX *)
ASN1_Type operator|(ASN1_Type x, ASN1_Type y)
constexpr uint64_t carry_shift(const donna128 &a, size_t shift)
BigInt operator*(const BigInt &x, const BigInt &y)
OctetString operator+(const OctetString &k1, const OctetString &k2)
void carry(int64_t &h0, int64_t &h1)
constexpr void mul64x64_128(uint64_t a, uint64_t b, uint64_t *lo, uint64_t *hi)
constexpr uint64_t combine_lower(const donna128 &a, size_t s1, const donna128 &b, size_t s2)