-
+ 340744F79D1466A916FCA829C66F86915B808800BF3EBE2CCADABA1D5FD89EF5C5DB486C94B0F01ACE52F13D7A74784B68214499F5AC120AC8449FC9EB5C61C3
mpi/mpih-mul2.c
(0 . 0)(1 . 65)
9911 /* mpihelp-mul_2.c - MPI helper functions
9912 * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
9913 *
9914 * This file is part of GnuPG.
9915 *
9916 * GnuPG is free software; you can redistribute it and/or modify
9917 * it under the terms of the GNU General Public License as published by
9918 * the Free Software Foundation; either version 3 of the License, or
9919 * (at your option) any later version.
9920 *
9921 * GnuPG is distributed in the hope that it will be useful,
9922 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9923 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9924 * GNU General Public License for more details.
9925 *
9926 * You should have received a copy of the GNU General Public License
9927 * along with this program; if not, see <http://www.gnu.org/licenses/>.
9928 *
9929 * Note: This code is heavily based on the GNU MP Library.
9930 * Actually it's the same code with only minor changes in the
9931 * way the data is stored; this is to support the abstraction
9932 * of an optional secure memory allocation which may be used
9933 * to avoid revealing of sensitive data due to paging etc.
9934 * The GNU MP Library itself is published under the LGPL;
9935 * however I decided to publish this code under the plain GPL.
9936 */
9937
9938 #include <config.h>
9939 #include <stdio.h>
9940 #include <stdlib.h>
9941 #include "mpi-internal.h"
9942 #include "longlong.h"
9943
9944
9945 mpi_limb_t
9946 mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
9947 mpi_size_t s1_size, mpi_limb_t s2_limb)
9948 {
9949 mpi_limb_t cy_limb;
9950 mpi_size_t j;
9951 mpi_limb_t prod_high, prod_low;
9952 mpi_limb_t x;
9953
9954 /* The loop counter and index J goes from -SIZE to -1. This way
9955 * the loop becomes faster. */
9956 j = -s1_size;
9957 res_ptr -= j;
9958 s1_ptr -= j;
9959
9960 cy_limb = 0;
9961 do {
9962 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
9963
9964 prod_low += cy_limb;
9965 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
9966
9967 x = res_ptr[j];
9968 prod_low = x + prod_low;
9969 cy_limb += prod_low < x?1:0;
9970 res_ptr[j] = prod_low;
9971 } while ( ++j );
9972 return cy_limb;
9973 }
9974
9975