aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils/donna128.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-12-11 15:28:38 -0500
committerJack Lloyd <[email protected]>2016-12-18 16:48:24 -0500
commitf3cb3edb512bdcab498d825886c3366c341b3f78 (patch)
tree645c73ec295a5a34f25d99903b6d9fa9751e86d3 /src/lib/utils/donna128.h
parentc1dd21253c1f3188ff45d3ad47698efd08235ae8 (diff)
Convert to using standard uintN_t integer types
Renames a couple of functions for somewhat better name consistency, eg make_u32bit becomes make_uint32. The old typedefs remain for now since probably lots of application code uses them.
Diffstat (limited to 'src/lib/utils/donna128.h')
-rw-r--r--src/lib/utils/donna128.h36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/lib/utils/donna128.h b/src/lib/utils/donna128.h
index 2a2d1e339..3e11f71c2 100644
--- a/src/lib/utils/donna128.h
+++ b/src/lib/utils/donna128.h
@@ -15,7 +15,7 @@ namespace Botan {
class donna128
{
public:
- donna128(u64bit ll = 0, u64bit hh = 0) { l = ll; h = hh; }
+ donna128(uint64_t ll = 0, uint64_t hh = 0) { l = ll; h = hh; }
donna128(const donna128&) = default;
donna128& operator=(const donna128&) = default;
@@ -25,7 +25,7 @@ class donna128
donna128 z = x;
if(shift > 0)
{
- const u64bit carry = z.h << (64 - shift);
+ const uint64_t carry = z.h << (64 - shift);
z.h = (z.h >> shift);
z.l = (z.l >> shift) | carry;
}
@@ -37,19 +37,19 @@ class donna128
donna128 z = x;
if(shift > 0)
{
- const u64bit carry = z.l >> (64 - shift);
+ const uint64_t carry = z.l >> (64 - shift);
z.l = (z.l << shift);
z.h = (z.h << shift) | carry;
}
return z;
}
- friend u64bit operator&(const donna128& x, u64bit mask)
+ friend uint64_t operator&(const donna128& x, uint64_t mask)
{
return x.l & mask;
}
- u64bit operator&=(u64bit mask)
+ uint64_t operator&=(uint64_t mask)
{
h = 0;
l &= mask;
@@ -64,24 +64,24 @@ class donna128
return *this;
}
- donna128& operator+=(u64bit x)
+ donna128& operator+=(uint64_t x)
{
l += x;
h += (l < x);
return *this;
}
- u64bit lo() const { return l; }
- u64bit hi() const { return h; }
+ uint64_t lo() const { return l; }
+ uint64_t hi() const { return h; }
private:
- u64bit h = 0, l = 0;
+ uint64_t h = 0, l = 0;
};
-inline donna128 operator*(const donna128& x, u64bit y)
+inline donna128 operator*(const donna128& x, uint64_t y)
{
BOTAN_ASSERT(x.hi() == 0, "High 64 bits of donna128 set to zero during multiply");
- u64bit lo = 0, hi = 0;
+ uint64_t lo = 0, hi = 0;
mul64x64_128(x.lo(), y, &lo, &hi);
return donna128(lo, hi);
}
@@ -93,7 +93,7 @@ inline donna128 operator+(const donna128& x, const donna128& y)
return z;
}
-inline donna128 operator+(const donna128& x, u64bit y)
+inline donna128 operator+(const donna128& x, uint64_t y)
{
donna128 z = x;
z += y;
@@ -105,12 +105,12 @@ inline donna128 operator|(const donna128& x, const donna128& y)
return donna128(x.lo() | y.lo(), x.hi() | y.hi());
}
-inline u64bit carry_shift(const donna128& a, size_t shift)
+inline uint64_t carry_shift(const donna128& a, size_t shift)
{
return (a >> shift).lo();
}
-inline u64bit combine_lower(const donna128& a, size_t s1,
+inline uint64_t combine_lower(const donna128& a, size_t s1,
const donna128& b, size_t s2)
{
donna128 z = (a >> s1) | (b << s2);
@@ -118,15 +118,15 @@ inline u64bit combine_lower(const donna128& a, size_t s1,
}
#if defined(BOTAN_TARGET_HAS_NATIVE_UINT128)
-inline u64bit carry_shift(const uint128_t a, size_t shift)
+inline uint64_t carry_shift(const uint128_t a, size_t shift)
{
- return static_cast<u64bit>(a >> shift);
+ return static_cast<uint64_t>(a >> shift);
}
-inline u64bit combine_lower(const uint128_t a, size_t s1,
+inline uint64_t combine_lower(const uint128_t a, size_t s1,
const uint128_t b, size_t s2)
{
- return static_cast<u64bit>((a >> s1) | (b << s2));
+ return static_cast<uint64_t>((a >> s1) | (b << s2));
}
#endif