Botan 3.9.0
Crypto and TLS for C&
Botan::donna128 Class Referencefinal

#include <donna128.h>

Public Member Functions

constexpr donna128 (uint64_t l=0, uint64_t h=0)
constexpr uint64_t hi () const
constexpr uint64_t lo () const
constexpr operator uint64_t () const
constexpr uint64_t operator&= (uint64_t mask)
constexpr donna128operator+= (const donna128 &x)
constexpr donna128operator+= (uint64_t x)

Friends

constexpr friend uint64_t operator& (const donna128 &x, uint64_t mask)
template<std::unsigned_integral T>
constexpr friend donna128 operator<< (const donna128 &x, T shift)
template<std::unsigned_integral T>
constexpr friend donna128 operator>> (const donna128 &x, T shift)

Detailed Description

Definition at line 17 of file donna128.h.

Constructor & Destructor Documentation

◆ donna128()

Botan::donna128::donna128 ( uint64_t l = 0,
uint64_t h = 0 )
inlineexplicitconstexpr

Definition at line 19 of file donna128.h.

19: m_lo(l), m_hi(h) {}

Referenced by operator&, operator+=(), operator+=(), operator<<, and operator>>.

Member Function Documentation

◆ hi()

uint64_t Botan::donna128::hi ( ) const
inlineconstexpr

Definition at line 85 of file donna128.h.

85{ return m_hi; }

Referenced by Botan::operator*(), Botan::operator|(), and Botan::operator|().

◆ lo()

uint64_t Botan::donna128::lo ( ) const
inlineconstexpr

Definition at line 83 of file donna128.h.

83{ return m_lo; }

Referenced by Botan::combine_lower(), operator uint64_t(), Botan::operator*(), Botan::operator|(), and Botan::operator|().

◆ operator uint64_t()

Botan::donna128::operator uint64_t ( ) const
inlineexplicitconstexpr

Definition at line 87 of file donna128.h.

87{ return lo(); }
constexpr uint64_t lo() const
Definition donna128.h:83

References lo().

◆ operator&=()

uint64_t Botan::donna128::operator&= ( uint64_t mask)
inlineconstexpr

Definition at line 61 of file donna128.h.

61 {
62 m_hi = 0;
63 m_lo &= mask;
64 return m_lo;
65 }

◆ operator+=() [1/2]

donna128 & Botan::donna128::operator+= ( const donna128 & x)
inlineconstexpr

Definition at line 67 of file donna128.h.

67 {
68 m_lo += x.m_lo;
69 m_hi += x.m_hi;
70
71 const uint64_t carry = CT::Mask<uint64_t>::is_lt(m_lo, x.m_lo).if_set_return(1);
72 m_hi += carry;
73 return *this;
74 }
static constexpr Mask< T > is_lt(T x, T y)
Definition ct_utils.h:478
void carry(int64_t &h0, int64_t &h1)

References Botan::carry(), donna128(), and Botan::CT::Mask< T >::is_lt().

◆ operator+=() [2/2]

donna128 & Botan::donna128::operator+= ( uint64_t x)
inlineconstexpr

Definition at line 76 of file donna128.h.

76 {
77 m_lo += x;
78 const uint64_t carry = CT::Mask<uint64_t>::is_lt(m_lo, x).if_set_return(1);
79 m_hi += carry;
80 return *this;
81 }

References Botan::carry(), donna128(), and Botan::CT::Mask< T >::is_lt().

◆ operator&

friend uint64_t operator& ( const donna128 & x,
uint64_t mask )
friend

Definition at line 59 of file donna128.h.

59{ return x.m_lo & mask; }

References donna128().

◆ operator<<

template<std::unsigned_integral T>
friend donna128 operator<< ( const donna128 & x,
T shift )
friend

Definition at line 42 of file donna128.h.

42 {
43 donna128 z = x;
44 if(shift > 64) {
45 z.m_hi = z.m_lo << (shift - 64);
46 z.m_lo = 0;
47 } else if(shift == 64) {
48 z.m_hi = z.m_lo;
49 z.m_lo = 0;
50 } else if(shift > 0) {
51 const uint64_t carry = z.m_lo >> static_cast<size_t>(64 - shift);
52 z.m_lo = (z.m_lo << shift);
53 z.m_hi = (z.m_hi << shift) | carry;
54 }
55
56 return z;
57 }
constexpr donna128(uint64_t l=0, uint64_t h=0)
Definition donna128.h:19

References Botan::carry(), and donna128().

◆ operator>>

template<std::unsigned_integral T>
friend donna128 operator>> ( const donna128 & x,
T shift )
friend

Definition at line 22 of file donna128.h.

22 {
23 donna128 z = x;
24
25 if(shift > 64) {
26 z.m_lo = z.m_hi >> (shift - 64);
27 z.m_hi = 0;
28 } else if(shift == 64) {
29 z.m_lo = z.m_hi;
30 z.m_hi = 0;
31 } else if(shift > 0) {
32 const uint64_t carry = z.m_hi << static_cast<size_t>(64 - shift);
33 z.m_hi >>= shift;
34 z.m_lo >>= shift;
35 z.m_lo |= carry;
36 }
37
38 return z;
39 }

References Botan::carry(), and donna128().


The documentation for this class was generated from the following file: