diff options
author | lloyd <[email protected]> | 2014-08-09 16:13:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-08-09 16:13:59 +0000 |
commit | 90cd8ae0572f907ddbe6158a493a748616176039 (patch) | |
tree | f423cc85f3f94e5db0997d7d332941a195ad0402 /src/lib | |
parent | 99ad1cc84bb3099ad236ade3a47d7134a5f85d40 (diff) |
Asserts here are nice
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/math/mp/mp_asm.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/math/mp/mp_asm.cpp b/src/lib/math/mp/mp_asm.cpp index a3caba620..78fbba3d8 100644 --- a/src/lib/math/mp/mp_asm.cpp +++ b/src/lib/math/mp/mp_asm.cpp @@ -23,6 +23,8 @@ word bigint_add2_nc(word x[], size_t x_size, const word y[], size_t y_size) { word carry = 0; + BOTAN_ASSERT(x_size >= y_size, "Expected sizes"); + const size_t blocks = y_size - (y_size % 8); for(size_t i = 0; i != blocks; i += 8) @@ -88,6 +90,8 @@ word bigint_sub2(word x[], size_t x_size, const word y[], size_t y_size) { word borrow = 0; + BOTAN_ASSERT(x_size >= y_size, "Expected sizes"); + const size_t blocks = y_size - (y_size % 8); for(size_t i = 0; i != blocks; i += 8) @@ -117,8 +121,7 @@ void bigint_sub2_rev(word x[], const word y[], size_t y_size) for(size_t i = blocks; i != y_size; ++i) x[i] = word_sub(y[i], x[i], &borrow); - if(borrow) - throw Internal_Error("bigint_sub2_rev: x >= y"); + BOTAN_ASSERT(!borrow, "y must be greater than x"); } /* @@ -129,6 +132,8 @@ word bigint_sub3(word z[], const word x[], size_t x_size, { word borrow = 0; + BOTAN_ASSERT(x_size >= y_size, "Expected sizes"); + const size_t blocks = y_size - (y_size % 8); for(size_t i = 0; i != blocks; i += 8) |