-
+ A6703D0851FB4F5A7C05EA94B0EA1C9DF3B79379B43C55EF10481496984DC6B58C3B26FC009607EDE37917758CC7576065049C5A511EEE7E0B9048E1A1B06654
eucrypt/mpi/mpih-mul3.c
(0 . 0)(1 . 62)
6385 /* mpihelp-mul_3.c - MPI helper functions
6386 * Modified by No Such Labs. (C) 2015. See README.
6387 *
6388 * This file was originally part of Gnu Privacy Guard (GPG), ver. 1.4.10,
6389 * SHA256(gnupg-1.4.10.tar.gz):
6390 * 0bfd74660a2f6cedcf7d8256db4a63c996ffebbcdc2cf54397bfb72878c5a85a
6391 * (C) 1994-2005 Free Software Foundation, Inc.
6392 *
6393 * This program is free software: you can redistribute it and/or modify
6394 * it under the terms of the GNU General Public License as published by
6395 * the Free Software Foundation, either version 3 of the License, or
6396 * (at your option) any later version.
6397 *
6398 * This program is distributed in the hope that it will be useful,
6399 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6400 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6401 * GNU General Public License for more details.
6402 *
6403 * You should have received a copy of the GNU General Public License
6404 * along with this program. If not, see <http://www.gnu.org/licenses/>.
6405 */
6406
6407 #include <stdio.h>
6408 #include <stdlib.h>
6409
6410 #include "knobs.h"
6411 #include "mpi-internal.h"
6412 #include "longlong.h"
6413
6414
6415 mpi_limb_t
6416 mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
6417 mpi_size_t s1_size, mpi_limb_t s2_limb)
6418 {
6419 mpi_limb_t cy_limb;
6420 mpi_size_t j;
6421 mpi_limb_t prod_high, prod_low;
6422 mpi_limb_t x;
6423
6424 /* The loop counter and index J goes from -SIZE to -1. This way
6425 * the loop becomes faster. */
6426 j = -s1_size;
6427 res_ptr -= j;
6428 s1_ptr -= j;
6429
6430 cy_limb = 0;
6431 do {
6432 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb);
6433
6434 prod_low += cy_limb;
6435 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
6436
6437 x = res_ptr[j];
6438 prod_low = x - prod_low;
6439 cy_limb += prod_low > x?1:0;
6440 res_ptr[j] = prod_low;
6441 } while( ++j );
6442
6443 return cy_limb;
6444 }
6445
6446