aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/math/bigint/big_ops2.cpp19
-rw-r--r--src/lib/math/bigint/bigint.h6
2 files changed, 23 insertions, 2 deletions
diff --git a/src/lib/math/bigint/big_ops2.cpp b/src/lib/math/bigint/big_ops2.cpp
index 2f81989c3..7653884c9 100644
--- a/src/lib/math/bigint/big_ops2.cpp
+++ b/src/lib/math/bigint/big_ops2.cpp
@@ -107,12 +107,12 @@ BigInt& BigInt::operator*=(const BigInt& y)
}
else if(x_sw == 1 && y_sw)
{
- grow_to(y_sw + 2);
+ grow_to(y_sw + 1);
bigint_linmul3(mutable_data(), y.data(), y_sw, word_at(0));
}
else if(y_sw == 1 && x_sw)
{
- grow_to(x_sw + 2);
+ grow_to(x_sw + 1);
bigint_linmul2(mutable_data(), x_sw, y.word_at(0));
}
else
@@ -125,6 +125,21 @@ BigInt& BigInt::operator*=(const BigInt& y)
return (*this);
}
+BigInt& BigInt::operator*=(word y)
+ {
+ if(y == 0)
+ {
+ clear();
+ set_sign(Positive);
+ }
+
+ const size_t x_sw = sig_words();
+ grow_to(x_sw + 1);
+ bigint_linmul2(mutable_data(), x_sw, y);
+
+ return (*this);
+ }
+
/*
* Division Operator
*/
diff --git a/src/lib/math/bigint/bigint.h b/src/lib/math/bigint/bigint.h
index 71629b3aa..2c1d5e905 100644
--- a/src/lib/math/bigint/bigint.h
+++ b/src/lib/math/bigint/bigint.h
@@ -154,6 +154,12 @@ class BOTAN_PUBLIC_API(2,0) BigInt final
BigInt& operator*=(const BigInt& y);
/**
+ * *= operator
+ * @param y the word to multiply with this
+ */
+ BigInt& operator*=(word y);
+
+ /**
* /= operator
* @param y the BigInt to divide this by
*/