![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 /* mpihelp-mul_2.c - MPI helper functions 0003 * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc. 0004 * 0005 * This file is part of GnuPG. 0006 * 0007 * Note: This code is heavily based on the GNU MP Library. 0008 * Actually it's the same code with only minor changes in the 0009 * way the data is stored; this is to support the abstraction 0010 * of an optional secure memory allocation which may be used 0011 * to avoid revealing of sensitive data due to paging etc. 0012 * The GNU MP Library itself is published under the LGPL; 0013 * however I decided to publish this code under the plain GPL. 0014 */ 0015 0016 #include "mpi-internal.h" 0017 #include "longlong.h" 0018 0019 mpi_limb_t 0020 mpihelp_addmul_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, 0021 mpi_size_t s1_size, mpi_limb_t s2_limb) 0022 { 0023 mpi_limb_t cy_limb; 0024 mpi_size_t j; 0025 mpi_limb_t prod_high, prod_low; 0026 mpi_limb_t x; 0027 0028 /* The loop counter and index J goes from -SIZE to -1. This way 0029 * the loop becomes faster. */ 0030 j = -s1_size; 0031 res_ptr -= j; 0032 s1_ptr -= j; 0033 0034 cy_limb = 0; 0035 do { 0036 umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); 0037 0038 prod_low += cy_limb; 0039 cy_limb = (prod_low < cy_limb ? 1 : 0) + prod_high; 0040 0041 x = res_ptr[j]; 0042 prod_low = x + prod_low; 0043 cy_limb += prod_low < x ? 1 : 0; 0044 res_ptr[j] = prod_low; 0045 } while (++j); 0046 return cy_limb; 0047 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |