Botan 3.4.0
Crypto and TLS for C&
Public Member Functions | Friends | List of all members
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 16 of file donna128.h.

Constructor & Destructor Documentation

◆ donna128() [1/2]

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

Definition at line 18 of file donna128.h.

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

◆ donna128() [2/2]

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

Member Function Documentation

◆ hi()

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

Definition at line 90 of file donna128.h.

90{ return h; }

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

◆ lo()

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

Definition at line 88 of file donna128.h.

88{ return l; }

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

◆ operator uint64_t()

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

Definition at line 92 of file donna128.h.

92{ return l; }

◆ operator&=()

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

Definition at line 66 of file donna128.h.

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

◆ operator+=() [1/2]

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

Definition at line 72 of file donna128.h.

72 {
73 l += x.l;
74 h += x.h;
75
76 const uint64_t carry = (l < x.l);
77 h += carry;
78 return *this;
79 }
void carry(int64_t &h0, int64_t &h1)

References Botan::carry().

◆ operator+=() [2/2]

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

Definition at line 81 of file donna128.h.

81 {
82 l += x;
83 const uint64_t carry = (l < x);
84 h += carry;
85 return *this;
86 }

References Botan::carry().

◆ operator=()

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

Friends And Related Symbol Documentation

◆ operator&

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

Definition at line 64 of file donna128.h.

64{ return x.l & mask; }

◆ operator<<

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

Definition at line 47 of file donna128.h.

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

◆ operator>>

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

Definition at line 27 of file donna128.h.

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

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