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

#include <donna128.h>

Public Member Functions

 donna128 (const donna128 &)=default
 
constexpr donna128 (uint64_t ll=0, uint64_t hh=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)
 
donna128operator= (const donna128 &)=default
 

Friends

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

Detailed Description

Definition at line 17 of file donna128.h.

Constructor & Destructor Documentation

◆ donna128() [1/2]

Botan::donna128::donna128 ( uint64_t ll = 0,
uint64_t hh = 0 )
inlineconstexpr

Definition at line 19 of file donna128.h.

19 {
20 l = ll;
21 h = hh;
22 }

◆ donna128() [2/2]

Botan::donna128::donna128 ( const donna128 & )
default

Member Function Documentation

◆ hi()

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

Definition at line 91 of file donna128.h.

91{ return h; }

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

◆ lo()

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

Definition at line 89 of file donna128.h.

89{ return l; }

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

◆ operator uint64_t()

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

Definition at line 93 of file donna128.h.

93{ return l; }

◆ operator&=()

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

Definition at line 67 of file donna128.h.

67 {
68 h = 0;
69 l &= mask;
70 return l;
71 }

◆ operator+=() [1/2]

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

Definition at line 73 of file donna128.h.

73 {
74 l += x.l;
75 h += x.h;
76
77 const uint64_t carry = CT::Mask<uint64_t>::is_lt(l, x.l).if_set_return(1);
78 h += carry;
79 return *this;
80 }
static constexpr Mask< T > is_lt(T x, T y)
Definition ct_utils.h:442
void carry(int64_t &h0, int64_t &h1)

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

◆ operator+=() [2/2]

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

Definition at line 82 of file donna128.h.

82 {
83 l += x;
84 const uint64_t carry = CT::Mask<uint64_t>::is_lt(l, x).if_set_return(1);
85 h += carry;
86 return *this;
87 }

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

◆ operator=()

donna128 & Botan::donna128::operator= ( const donna128 & )
default

Friends And Related Symbol Documentation

◆ operator&

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

Definition at line 65 of file donna128.h.

65{ return x.l & mask; }

◆ operator<<

template<typename T >
friend donna128 operator<< ( const donna128 & x,
T shift )
friend

Definition at line 48 of file donna128.h.

48 {
49 donna128 z = x;
50 if(shift > 64) {
51 z.h = z.l << (shift - 64);
52 z.l = 0;
53 } else if(shift == 64) {
54 z.h = z.l;
55 z.l = 0;
56 } else if(shift > 0) {
57 const uint64_t carry = z.l >> static_cast<size_t>(64 - shift);
58 z.l = (z.l << shift);
59 z.h = (z.h << shift) | carry;
60 }
61
62 return z;
63 }
constexpr donna128(uint64_t ll=0, uint64_t hh=0)
Definition donna128.h:19

◆ operator>>

template<typename T >
friend donna128 operator>> ( const donna128 & x,
T shift )
friend

Definition at line 28 of file donna128.h.

28 {
29 donna128 z = x;
30
31 if(shift > 64) {
32 z.l = z.h >> (shift - 64);
33 z.h = 0;
34 } else if(shift == 64) {
35 z.l = z.h;
36 z.h = 0;
37 } else if(shift > 0) {
38 const uint64_t carry = z.h << static_cast<size_t>(64 - shift);
39 z.h >>= shift;
40 z.l >>= shift;
41 z.l |= carry;
42 }
43
44 return z;
45 }

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