![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 /* mpihelp-mul_1.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_mul_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, 0021 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 0027 /* The loop counter and index J goes from -S1_SIZE to -1. This way 0028 * the loop becomes faster. */ 0029 j = -s1_size; 0030 0031 /* Offset the base pointers to compensate for the negative indices. */ 0032 s1_ptr -= j; 0033 res_ptr -= j; 0034 0035 cy_limb = 0; 0036 do { 0037 umul_ppmm(prod_high, prod_low, s1_ptr[j], s2_limb); 0038 prod_low += cy_limb; 0039 cy_limb = (prod_low < cy_limb ? 1 : 0) + prod_high; 0040 res_ptr[j] = prod_low; 0041 } while (++j); 0042 0043 return cy_limb; 0044 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |