summaryrefslogtreecommitdiff
path: root/mpi/mpi-scan.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1997-11-27 11:44:11 +0000
committerWerner Koch <wk@gnupg.org>1997-11-27 11:44:11 +0000
commiteafd2c960e593d7e99e3f45575b3baf714a2a5ef (patch)
tree676d57f6b4d1c6585cb4584a914e5e9fc775449f /mpi/mpi-scan.c
parent10a1a07b306b5fc7f1682a03c576c1adecd4a458 (diff)
downloadlibgcrypt-eafd2c960e593d7e99e3f45575b3baf714a2a5ef.tar.gz
Improved prime number test
Diffstat (limited to 'mpi/mpi-scan.c')
-rw-r--r--mpi/mpi-scan.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c
index 8626032a..b9745e1a 100644
--- a/mpi/mpi-scan.c
+++ b/mpi/mpi-scan.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "mpi-internal.h"
+#include "longlong.h"
/****************
* Scan through an mpi and return byte for byte. a -1 is returned to indicate
@@ -86,3 +87,28 @@ mpi_putbyte( MPI a, unsigned index, int c )
abort(); /* index out of range */
}
+
+/****************
+ * Count the number of zerobits at the low end of A
+ */
+unsigned
+mpi_trailing_zeros( MPI a )
+{
+ unsigned n, count = 0;
+
+ for(n=0; n < a->nlimbs; n++ ) {
+ if( a->d[n] ) {
+ unsigned nn;
+ mpi_limb_t alimb = a->d[n];
+
+ count_trailing_zeros( nn, alimb );
+ count += nn;
+ break;
+ }
+ count += BITS_PER_MPI_LIMB;
+ }
+ return count;
+
+}
+
+