mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Improved prime number test
This commit is contained in:
parent
9479cf7e24
commit
649eae8f1b
10 changed files with 392 additions and 267 deletions
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue