diff options
-rw-r--r-- | src/lib/math/mp/mp_core.h | 7 | ||||
-rw-r--r-- | src/tests/data/bn/mod.vec | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/math/mp/mp_core.h b/src/lib/math/mp/mp_core.h index d01c13a5e..4c08a0a23 100644 --- a/src/lib/math/mp/mp_core.h +++ b/src/lib/math/mp/mp_core.h @@ -679,6 +679,13 @@ bigint_sub_abs(word z[], std::swap(x_size, y_size); } + /* + * We know at this point that x >= y so if y_size is larger than + * x_size, we are guaranteed they are just leading zeros which can + * be ignored + */ + y_size = std::min(x_size, y_size); + bigint_sub3(z, x, x_size, y, y_size); return relative_size; diff --git a/src/tests/data/bn/mod.vec b/src/tests/data/bn/mod.vec index 2d4196dbe..28e5a443b 100644 --- a/src/tests/data/bn/mod.vec +++ b/src/tests/data/bn/mod.vec @@ -299,3 +299,6 @@ In1 = -0x40147F79DA93E8D3F21A11E66D2F08F445BABB7AB7C3C2EF1B94312E6CBF347DC65831F In2 = 0x962EDDCC369CBA8EBB260EE6B6A126D9346E38C5 Output = 0x34889A4853583C9FC0163C085D8B74A1 +In1 = 200867255532373784442787963643582324255002321393966058045440 +In2 = 2535301200456458802993406410752 +Output = 0 |