aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/math/numbertheory
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2016-03-01 18:03:56 +0100
committerRenĂ© Korthaus <[email protected]>2016-04-19 20:42:25 +0200
commitd66b3ee6993a99e51cc2852b0356c386337a2d5c (patch)
tree648e1067146bb677809230e0e307198f6ff67b49 /src/lib/math/numbertheory
parenta4358c96a0de1ab7afc0b437ab79bfc35f2e1824 (diff)
Add ECGDSA
Diffstat (limited to 'src/lib/math/numbertheory')
-rw-r--r--src/lib/math/numbertheory/mp_numth.cpp14
-rw-r--r--src/lib/math/numbertheory/numthry.h11
2 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/math/numbertheory/mp_numth.cpp b/src/lib/math/numbertheory/mp_numth.cpp
index 6eb938286..3373b9ee7 100644
--- a/src/lib/math/numbertheory/mp_numth.cpp
+++ b/src/lib/math/numbertheory/mp_numth.cpp
@@ -71,4 +71,18 @@ BigInt sub_mul(const BigInt& a, const BigInt& b, const BigInt& c)
return r;
}
+/*
+* Multiply-Subtract Operation
+*/
+BigInt mul_sub(const BigInt& a, const BigInt& b, const BigInt& c)
+ {
+ if(c.is_negative() || c.is_zero())
+ throw Invalid_Argument("mul_sub: Third argument must be > 0");
+
+ BigInt r = a;
+ r *= b;
+ r -= c;
+ return r;
+ }
+
}
diff --git a/src/lib/math/numbertheory/numthry.h b/src/lib/math/numbertheory/numthry.h
index e1e6c65f6..591b61f6a 100644
--- a/src/lib/math/numbertheory/numthry.h
+++ b/src/lib/math/numbertheory/numthry.h
@@ -37,6 +37,17 @@ BigInt BOTAN_DLL sub_mul(const BigInt& a,
const BigInt& c);
/**
+* Fused multiply-subtract
+* @param a an integer
+* @param b an integer
+* @param c an integer
+* @return (a*b)-c
+*/
+BigInt BOTAN_DLL mul_sub(const BigInt& a,
+ const BigInt& b,
+ const BigInt& c);
+
+/**
* Return the absolute value
* @param n an integer
* @return absolute value of n