From 1c5fda515f96c27d4e3b732d887f418453f1cb14 Mon Sep 17 00:00:00 2001 From: Matt Johnston Date: Wed, 8 Mar 2006 13:16:18 +0000 Subject: Import of libtommath 0.35 From ltm-0.35.tar.bz2 SHA1 of 3f193dbae9351e92d02530994fa18236f7fde01c --HG-- branch : libtommath-orig extra : convert_revision : 2b4b13ac88b2a81e5c86ba868c92c6a452630e02 --- bn_mp_neg.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 bn_mp_neg.c (limited to 'bn_mp_neg.c') diff --git a/bn_mp_neg.c b/bn_mp_neg.c new file mode 100644 index 0000000..159cd74 --- /dev/null +++ b/bn_mp_neg.c @@ -0,0 +1,36 @@ +#include +#ifdef BN_MP_NEG_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@iahu.ca, http://math.libtomcrypt.org + */ + +/* b = -a */ +int mp_neg (mp_int * a, mp_int * b) +{ + int res; + if (a != b) { + if ((res = mp_copy (a, b)) != MP_OKAY) { + return res; + } + } + + if (mp_iszero(b) != MP_YES) { + b->sign = (a->sign == MP_ZPOS) ? MP_NEG : MP_ZPOS; + } else { + b->sign = MP_ZPOS; + } + + return MP_OKAY; +} +#endif -- cgit v1.2.3