-
+ 340744F79D1466A916FCA829C66F86915B808800BF3EBE2CCADABA1D5FD89EF5C5DB486C94B0F01ACE52F13D7A74784B68214499F5AC120AC8449FC9EB5C61C3
mpi/mpih-mul2.c
(0 . 0)(1 . 65)
8236 /* mpihelp-mul_2.c - MPI helper functions
8237 * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
8238 *
8239 * This file is part of GnuPG.
8240 *
8241 * GnuPG is free software; you can redistribute it and/or modify
8242 * it under the terms of the GNU General Public License as published by
8243 * the Free Software Foundation; either version 3 of the License, or
8244 * (at your option) any later version.
8245 *
8246 * GnuPG is distributed in the hope that it will be useful,
8247 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8248 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8249 * GNU General Public License for more details.
8250 *
8251 * You should have received a copy of the GNU General Public License
8252 * along with this program; if not, see <http://www.gnu.org/licenses/>.
8253 *
8254 * Note: This code is heavily based on the GNU MP Library.
8255 * Actually it's the same code with only minor changes in the
8256 * way the data is stored; this is to support the abstraction
8257 * of an optional secure memory allocation which may be used
8258 * to avoid revealing of sensitive data due to paging etc.
8259 * The GNU MP Library itself is published under the LGPL;
8260 * however I decided to publish this code under the plain GPL.
8261 */
8262
8263 #include <config.h>
8264 #include <stdio.h>
8265 #include <stdlib.h>
8266 #include "mpi-internal.h"
8267 #include "longlong.h"
8268
8269
8270 mpi_limb_t
8271 mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
8272 mpi_size_t s1_size, mpi_limb_t s2_limb)
8273 {
8274 mpi_limb_t cy_limb;
8275 mpi_size_t j;
8276 mpi_limb_t prod_high, prod_low;
8277 mpi_limb_t x;
8278
8279 /* The loop counter and index J goes from -SIZE to -1. This way
8280 * the loop becomes faster. */
8281 j = -s1_size;
8282 res_ptr -= j;
8283 s1_ptr -= j;
8284
8285 cy_limb = 0;
8286 do {
8287 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
8288
8289 prod_low += cy_limb;
8290 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
8291
8292 x = res_ptr[j];
8293 prod_low = x + prod_low;
8294 cy_limb += prod_low < x?1:0;
8295 res_ptr[j] = prod_low;
8296 } while ( ++j );
8297 return cy_limb;
8298 }
8299
8300