diff options
author | Jack Lloyd <[email protected]> | 2018-08-15 07:46:36 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-08-15 07:46:36 -0400 |
commit | b3e15b49ad0946b141c78ac9bf25ef654b0eb017 (patch) | |
tree | 21bcda657a9dd59eb9eff0df989cf5da17813955 /src/lib/math | |
parent | d4ab524798edd7609f9db7db5b050459fa7ad238 (diff) |
Remove support for 8 or 16 bit BigInt words
It turned out 8 bit was very broken (failed to compile, due to
overload problems with functions taking uint8_t vs word).
16 bit words work aside from a test failure, but is really slow.
Practically speaking we are not in a position to support 16-bit CPUs
very well. And being able to assume sizeof(word) >= sizeof(uint32_t)
allows simplifying some code.
Diffstat (limited to 'src/lib/math')
-rw-r--r-- | src/lib/math/mp/mp_madd.h | 11 | ||||
-rw-r--r-- | src/lib/math/numbertheory/curve_nistp.h | 4 | ||||
-rw-r--r-- | src/lib/math/numbertheory/nistp_redc.cpp | 8 |
3 files changed, 5 insertions, 18 deletions
diff --git a/src/lib/math/mp/mp_madd.h b/src/lib/math/mp/mp_madd.h index 4807fcd04..4f34efe39 100644 --- a/src/lib/math/mp/mp_madd.h +++ b/src/lib/math/mp/mp_madd.h @@ -14,15 +14,10 @@ namespace Botan { -#if (BOTAN_MP_WORD_BITS == 8) - typedef uint16_t dword; - #define BOTAN_HAS_MP_DWORD -#elif (BOTAN_MP_WORD_BITS == 16) - typedef uint32_t dword; - #define BOTAN_HAS_MP_DWORD -#elif (BOTAN_MP_WORD_BITS == 32) +#if (BOTAN_MP_WORD_BITS == 32) typedef uint64_t dword; #define BOTAN_HAS_MP_DWORD + #elif (BOTAN_MP_WORD_BITS == 64) #if defined(BOTAN_TARGET_HAS_NATIVE_UINT128) typedef uint128_t dword; @@ -32,7 +27,7 @@ namespace Botan { #endif #else - #error BOTAN_MP_WORD_BITS must be 8, 16, 32, or 64 + #error BOTAN_MP_WORD_BITS must be 32 or 64 #endif #if defined(BOTAN_TARGET_ARCH_IS_X86_32) && (BOTAN_MP_WORD_BITS == 32) diff --git a/src/lib/math/numbertheory/curve_nistp.h b/src/lib/math/numbertheory/curve_nistp.h index c9936a338..710b06dec 100644 --- a/src/lib/math/numbertheory/curve_nistp.h +++ b/src/lib/math/numbertheory/curve_nistp.h @@ -23,8 +23,6 @@ namespace Botan { BOTAN_PUBLIC_API(2,0) const BigInt& prime_p521(); BOTAN_PUBLIC_API(2,0) void redc_p521(BigInt& x, secure_vector<word>& ws); -#if (BOTAN_MP_WORD_BITS == 32) || (BOTAN_MP_WORD_BITS == 64) - #define BOTAN_HAS_NIST_PRIME_REDUCERS_W32 BOTAN_PUBLIC_API(2,0) const BigInt& prime_p384(); @@ -39,8 +37,6 @@ BOTAN_PUBLIC_API(2,0) void redc_p224(BigInt& x, secure_vector<word>& ws); BOTAN_PUBLIC_API(2,0) const BigInt& prime_p192(); BOTAN_PUBLIC_API(2,0) void redc_p192(BigInt& x, secure_vector<word>& ws); -#endif - } #endif diff --git a/src/lib/math/numbertheory/nistp_redc.cpp b/src/lib/math/numbertheory/nistp_redc.cpp index b74a2f9c6..1c2855784 100644 --- a/src/lib/math/numbertheory/nistp_redc.cpp +++ b/src/lib/math/numbertheory/nistp_redc.cpp @@ -91,10 +91,8 @@ inline uint32_t get_uint32_t(const BigInt& x, size_t i) { #if (BOTAN_MP_WORD_BITS == 32) return x.word_at(i); -#elif (BOTAN_MP_WORD_BITS == 64) - return static_cast<uint32_t>(x.word_at(i/2) >> ((i % 2)*32)); #else - #error "Not implemented" + return static_cast<uint32_t>(x.word_at(i/2) >> ((i % 2)*32)); #endif } @@ -103,10 +101,8 @@ inline void set_words(BigInt& x, size_t i, uint32_t R0, uint32_t R1) #if (BOTAN_MP_WORD_BITS == 32) x.set_word_at(i, R0); x.set_word_at(i+1, R1); -#elif (BOTAN_MP_WORD_BITS == 64) - x.set_word_at(i/2, (static_cast<uint64_t>(R1) << 32) | R0); #else - #error "Not implemented" + x.set_word_at(i/2, (static_cast<uint64_t>(R1) << 32) | R0); #endif } |