-
+ EAF2827058A07C1502EA5DA210AE7B7662B6B02AC4847D37467FB498DDB84D592CCE814DB4B15588DA8C5349E4FFE4636D267FEDF0ECEB29E63BD8DCF0249BE2
eucrypt/mpi/mpi-scan.c
(0 . 0)(1 . 56)
4603 /* mpi-scan.c - MPI functions
4604 * Modified by No Such Labs. (C) 2015. See README.
4605 * Modified by S.MG 2017 (removed code that is not used by eucrypt and at the same time so ugly it needs rewrite anyway)
4606 *
4607 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
4608 * SHA256(gnupg-1.4.10.tar.gz):
4609 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
4610 * (C) 1994-2005 Free Software Foundation, Inc.
4611 *
4612 * This program is free software: you can redistribute it and/or modify
4613 * it under the terms of the GNU General Public License as published by
4614 * the Free Software Foundation, either version 3 of the License, or
4615 * (at your option) any later version.
4616 *
4617 * This program is distributed in the hope that it will be useful,
4618 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4619 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4620 * GNU General Public License for more details.
4621 *
4622 * You should have received a copy of the GNU General Public License
4623 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4624 */
4625
4626 #include <stdio.h>
4627 #include <stdlib.h>
4628
4629 #include "knobs.h"
4630 #include "mpi-internal.h"
4631 #include "longlong.h"
4632
4633
4634 /****************
4635 * Count the number of zerobits at the low end of A
4636 * This is used currently by eucrypt's primality tests.
4637 */
4638 unsigned int
4639 mpi_trailing_zeros( MPI a )
4640 {
4641 unsigned n, count = 0;
4642
4643 for(n=0; n < a->nlimbs; n++ ) {
4644 if( a->d[n] ) {
4645 unsigned nn;
4646 mpi_limb_t alimb = a->d[n];
4647
4648 count_trailing_zeros( nn, alimb );
4649 count += nn;
4650 break;
4651 }
4652 count += BITS_PER_MPI_LIMB;
4653 }
4654 return count;
4655
4656 }
4657
4658