mpi-genesis 1
mpi_second_cut 2 * Modified by No Such Labs. (C) 2015. See README.
sane_mpi_eucrypt 3 * Modified by S.MG 2017 (removed code that is not used by eucrypt and at the same time so ugly it needs rewrite anyway)
mpi-genesis 4 *
mpi_second_cut 5 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
mpi_second_cut 6 * SHA256(gnupg-1.4.10.tar.gz):
mpi_second_cut 7 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
mpi_second_cut 8 * (C) 1994-2005 Free Software Foundation, Inc.
mpi-genesis 9 *
mpi_second_cut 10 * This program is free software: you can redistribute it and/or modify
mpi-genesis 11 * it under the terms of the GNU General Public License as published by
mpi_second_cut 12 * the Free Software Foundation, either version 3 of the License, or
mpi-genesis 13 * (at your option) any later version.
mpi-genesis 14 *
mpi_second_cut 15 * This program is distributed in the hope that it will be useful,
mpi-genesis 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mpi-genesis 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
mpi-genesis 18 * GNU General Public License for more details.
mpi-genesis 19 *
mpi-genesis 20 * You should have received a copy of the GNU General Public License
mpi_second_cut 21 * along with this program. If not, see <http:
mpi-genesis 22 */
mpi_second_cut 23
mpi-genesis 24 #include <stdio.h>
mpi-genesis 25 #include <stdlib.h>
mpi_second_cut 26
mpi_second_cut 27 #include "knobs.h"
mpi-genesis 28 #include "mpi-internal.h"
mpi-genesis 29 #include "longlong.h"
mpi-genesis 30
mpi-genesis 31
mpi-genesis 32
mpi-genesis 33 * Count the number of zerobits at the low end of A
sane_mpi_eucrypt 34 * This is used currently by eucrypt's primality tests.
mpi-genesis 35 */
mpi-genesis 36 unsigned int
mpi-genesis 37 mpi_trailing_zeros( MPI a )
mpi-genesis 38 {
mpi-genesis 39 unsigned n, count = 0;
mpi-genesis 40
mpi-genesis 41 for(n=0; n < a->nlimbs; n++ ) {
mpi-genesis 42 if( a->d[n] ) {
mpi-genesis 43 unsigned nn;
mpi-genesis 44 mpi_limb_t alimb = a->d[n];
mpi-genesis 45
mpi-genesis 46 count_trailing_zeros( nn, alimb );
mpi-genesis 47 count += nn;
mpi-genesis 48 break;
mpi-genesis 49 }
mpi-genesis 50 count += BITS_PER_MPI_LIMB;
mpi-genesis 51 }
mpi-genesis 52 return count;
mpi-genesis 53
mpi-genesis 54 }
mpi-genesis 55
mpi-genesis 56