-
+ 3B4CC6335137AE38D7A62B34E1D2319C33371D77B6169AB101B4DF8CE83EE7E10FF859F24626B13AE42AFF8CFFC805FFAA433D53FAF56C5924837AC1FAC0A6F9
eucrypt/mpi/mpih-mul2.c
(0 . 0)(1 . 61)
6320 /* mpihelp-mul_2.c - MPI helper functions
6321 * Modified by No Such Labs. (C) 2015. See README.
6322 *
6323 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
6324 * SHA256(gnupg-1.4.10.tar.gz):
6325 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
6326 * (C) 1994-2005 Free Software Foundation, Inc.
6327 *
6328 * This program is free software: you can redistribute it and/or modify
6329 * it under the terms of the GNU General Public License as published by
6330 * the Free Software Foundation, either version 3 of the License, or
6331 * (at your option) any later version.
6332 *
6333 * This program is distributed in the hope that it will be useful,
6334 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6335 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6336 * GNU General Public License for more details.
6337 *
6338 * You should have received a copy of the GNU General Public License
6339 * along with this program. If not, see <http://www.gnu.org/licenses/>.
6340 */
6341
6342 #include <stdio.h>
6343 #include <stdlib.h>
6344
6345 #include "knobs.h"
6346 #include "mpi-internal.h"
6347 #include "longlong.h"
6348
6349
6350 mpi_limb_t
6351 mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
6352 mpi_size_t s1_size, mpi_limb_t s2_limb)
6353 {
6354 mpi_limb_t cy_limb;
6355 mpi_size_t j;
6356 mpi_limb_t prod_high, prod_low;
6357 mpi_limb_t x;
6358
6359 /* The loop counter and index J goes from -SIZE to -1. This way
6360 * the loop becomes faster. */
6361 j = -s1_size;
6362 res_ptr -= j;
6363 s1_ptr -= j;
6364
6365 cy_limb = 0;
6366 do {
6367 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
6368
6369 prod_low += cy_limb;
6370 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
6371
6372 x = res_ptr[j];
6373 prod_low = x + prod_low;
6374 cy_limb += prod_low < x?1:0;
6375 res_ptr[j] = prod_low;
6376 } while ( ++j );
6377 return cy_limb;
6378 }
6379
6380