summaryrefslogtreecommitdiff
path: root/libtommath/bn_mp_complement.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtommath/bn_mp_complement.c')
-rw-r--r--libtommath/bn_mp_complement.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libtommath/bn_mp_complement.c b/libtommath/bn_mp_complement.c
new file mode 100644
index 0000000..fef1423
--- /dev/null
+++ b/libtommath/bn_mp_complement.c
@@ -0,0 +1,12 @@
+#include "tommath_private.h"
+#ifdef BN_MP_COMPLEMENT_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+/* b = ~a */
+mp_err mp_complement(const mp_int *a, mp_int *b)
+{
+ mp_err err = mp_neg(a, b);
+ return (err == MP_OKAY) ? mp_sub_d(b, 1uL, b) : err;
+}
+#endif