aboutsummaryrefslogtreecommitdiffstats
path: root/mpi/mpih-sub.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpi/mpih-sub.c')
-rw-r--r--mpi/mpih-sub.c47
1 files changed, 11 insertions, 36 deletions
diff --git a/mpi/mpih-sub.c b/mpi/mpih-sub.c
index 3831d81c3..0864ef8f0 100644
--- a/mpi/mpih-sub.c
+++ b/mpi/mpih-sub.c
@@ -1,5 +1,6 @@
/* mpihelp-sub.c - MPI helper functions
* Copyright (c) 1997 by Werner Koch (dd9jn)
+ * Copyright (C) 1994, 1996 Free Software Foundation, Inc.
*
* This file is part of G10.
*
@@ -16,6 +17,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note: This code is heavily based on the GNU MP Library.
+ * Actually it's the same code with only minor changes in the
+ * way the data is stored; this is to support the abstraction
+ * of an optional secure memory allocation which may be used
+ * to avoid revealing of sensitive data due to paging etc.
+ * The GNU MP Library itself is published under the LGPL;
+ * however I decided to publish this code under the plain GPL.
*/
#include <config.h>
@@ -24,8 +33,7 @@
#include "mpi-internal.h"
-
-/*_EXTERN_INLINE*/
+#ifndef __GNUC__
mpi_limb_t
mpihelp_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_size_t s1_size, mpi_limb_t s2_limb )
@@ -55,39 +63,6 @@ mpihelp_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
}
-/* FIXME: this should be done in assembly */
-mpi_limb_t
-mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
- mpi_ptr_t s2_ptr, mpi_size_t size)
-{
- mpi_limb_t x, y, cy;
- mpi_size_t j;
-
- /* The loop counter and index J goes from -SIZE to -1. This way
- the loop becomes faster. */
- j = -size;
-
- /* Offset the base pointers to compensate for the negative indices. */
- s1_ptr -= j;
- s2_ptr -= j;
- res_ptr -= j;
-
- cy = 0;
- do {
- y = s2_ptr[j];
- x = s1_ptr[j];
- y += cy; /* add previous carry to subtrahend */
- cy = y < cy ? 1:0; /* get out carry from that addition */
- y = x - y; /* main subtract */
- cy += y > x? 1:0; /* get out carry from the subtract, combine */
- res_ptr[j] = y;
- } while( ++j );
-
- return cy;
-}
-
-
-/*_EXTERN_INLINE*/
mpi_limb_t
mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
mpi_ptr_t s2_ptr, mpi_size_t s2_size)
@@ -102,5 +77,5 @@ mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
s1_size - s2_size, cy);
return cy;
}
-
+#endif