summaryrefslogtreecommitdiffhomepage
path: root/libtommath/bn_mp_submod.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-01-11 04:29:08 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-01-11 04:29:08 +0000
commit943636c3e13f50bc0e29c5f69974541a296a3be2 (patch)
tree02a55d7bff75c51e641a556ad331460a1d1270b6 /libtommath/bn_mp_submod.c
parent0a60ef26bd13e6007c4fdd0f09b5a8d4785113c0 (diff)
parent9d5ed350a749368c84254c11e7616ce3c891193a (diff)
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head c1db4398d56c56c6d06ae1e20c1e0d04dbb598ed)
to branch 'au.asn.ucc.matt.dropbear' (head d26d5eb2837f46b56a33fb0e7573aa0201abd4d5) --HG-- extra : convert_revision : 7a0ae6de81402591a789486070007238169fafca
Diffstat (limited to 'libtommath/bn_mp_submod.c')
-rw-r--r--libtommath/bn_mp_submod.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/libtommath/bn_mp_submod.c b/libtommath/bn_mp_submod.c
new file mode 100644
index 0000000..bd24f25
--- /dev/null
+++ b/libtommath/bn_mp_submod.c
@@ -0,0 +1,42 @@
+#include <tommath.h>
+#ifdef BN_MP_SUBMOD_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis
+ *
+ * LibTomMath is a library that provides multiple-precision
+ * integer arithmetic as well as number theoretic functionality.
+ *
+ * The library was designed directly after the MPI library by
+ * Michael Fromberger but has been written from scratch with
+ * additional optimizations in place.
+ *
+ * The library is free for all purposes without any express
+ * guarantee it works.
+ *
+ * Tom St Denis, tomstdenis@gmail.com, http://math.libtomcrypt.com
+ */
+
+/* d = a - b (mod c) */
+int
+mp_submod (mp_int * a, mp_int * b, mp_int * c, mp_int * d)
+{
+ int res;
+ mp_int t;
+
+
+ if ((res = mp_init (&t)) != MP_OKAY) {
+ return res;
+ }
+
+ if ((res = mp_sub (a, b, &t)) != MP_OKAY) {
+ mp_clear (&t);
+ return res;
+ }
+ res = mp_mod (&t, c, d);
+ mp_clear (&t);
+ return res;
+}
+#endif
+
+/* $Source: /cvs/libtom/libtommath/bn_mp_submod.c,v $ */
+/* $Revision: 1.3 $ */
+/* $Date: 2006/03/31 14:18:44 $ */