8#ifndef BOTAN_CURVE25519_DONNA128_H_
9#define BOTAN_CURVE25519_DONNA128_H_
11#include <botan/internal/mul128.h>
18 constexpr donna128(uint64_t ll = 0, uint64_t hh = 0) {
31 z.l = z.h >> (shift - 64);
33 }
else if(shift == 64) {
36 }
else if(shift > 0) {
37 const uint64_t
carry = z.h <<
static_cast<size_t>(64 - shift);
50 z.h = z.l << (shift - 64);
52 }
else if(shift == 64) {
55 }
else if(shift > 0) {
56 const uint64_t
carry = z.l >>
static_cast<size_t>(64 - shift);
58 z.h = (z.h << shift) |
carry;
64 constexpr friend uint64_t
operator&(
const donna128& x, uint64_t mask) {
return x.l & mask; }
76 const uint64_t
carry = (l < x.l);
83 const uint64_t
carry = (l < x);
88 constexpr uint64_t
lo()
const {
return l; }
90 constexpr uint64_t
hi()
const {
return h; }
92 constexpr operator uint64_t()
const {
return l; }
95 uint64_t h = 0, l = 0;
98template <std::
unsigned_
integral T>
100 BOTAN_ARG_CHECK(x.
hi() == 0,
"High 64 bits of donna128 set to zero during multiply");
102 uint64_t lo = 0, hi = 0;
107template <std::
unsigned_
integral T>
133 return (a >> shift).lo();
141#if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
142inline uint64_t
carry_shift(
const uint128_t a,
size_t shift) {
143 return static_cast<uint64_t
>(a >> shift);
146inline uint64_t
combine_lower(
const uint128_t a,
size_t s1,
const uint128_t b,
size_t s2) {
147 return static_cast<uint64_t
>((a >> s1) | (b << s2));
#define BOTAN_ARG_CHECK(expr, msg)
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)