-
+ 86B925ACDAEDFAAF9C7F7FF783DA4A049C62C8F63929BF288FDC8E4760DC9B451440ED5ED5F8549E8B2CCBD4F00175F068DE9DC337EEDFD8FAD8348D21F3ED13
mpi/mpih-mul1.c
(0 . 0)(1 . 60)
8172 /* mpihelp-mul_1.c - MPI helper functions
8173 * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
8174 *
8175 * This file is part of GnuPG.
8176 *
8177 * GnuPG is free software; you can redistribute it and/or modify
8178 * it under the terms of the GNU General Public License as published by
8179 * the Free Software Foundation; either version 3 of the License, or
8180 * (at your option) any later version.
8181 *
8182 * GnuPG is distributed in the hope that it will be useful,
8183 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8184 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8185 * GNU General Public License for more details.
8186 *
8187 * You should have received a copy of the GNU General Public License
8188 * along with this program; if not, see <http://www.gnu.org/licenses/>.
8189 *
8190 * Note: This code is heavily based on the GNU MP Library.
8191 * Actually it's the same code with only minor changes in the
8192 * way the data is stored; this is to support the abstraction
8193 * of an optional secure memory allocation which may be used
8194 * to avoid revealing of sensitive data due to paging etc.
8195 * The GNU MP Library itself is published under the LGPL;
8196 * however I decided to publish this code under the plain GPL.
8197 */
8198
8199 #include <config.h>
8200 #include <stdio.h>
8201 #include <stdlib.h>
8202 #include "mpi-internal.h"
8203 #include "longlong.h"
8204
8205 mpi_limb_t
8206 mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
8207 mpi_limb_t s2_limb)
8208 {
8209 mpi_limb_t cy_limb;
8210 mpi_size_t j;
8211 mpi_limb_t prod_high, prod_low;
8212
8213 /* The loop counter and index J goes from -S1_SIZE to -1. This way
8214 * the loop becomes faster. */
8215 j = -s1_size;
8216
8217 /* Offset the base pointers to compensate for the negative indices. */
8218 s1_ptr -= j;
8219 res_ptr -= j;
8220
8221 cy_limb = 0;
8222 do {
8223 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
8224 prod_low += cy_limb;
8225 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
8226 res_ptr[j] = prod_low;
8227 } while( ++j );
8228
8229 return cy_limb;
8230 }
8231