-
+ 86B925ACDAEDFAAF9C7F7FF783DA4A049C62C8F63929BF288FDC8E4760DC9B451440ED5ED5F8549E8B2CCBD4F00175F068DE9DC337EEDFD8FAD8348D21F3ED13
mpi/mpih-mul1.c
(0 . 0)(1 . 60)
9847 /* mpihelp-mul_1.c - MPI helper functions
9848 * Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
9849 *
9850 * This file is part of GnuPG.
9851 *
9852 * GnuPG is free software; you can redistribute it and/or modify
9853 * it under the terms of the GNU General Public License as published by
9854 * the Free Software Foundation; either version 3 of the License, or
9855 * (at your option) any later version.
9856 *
9857 * GnuPG is distributed in the hope that it will be useful,
9858 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9859 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9860 * GNU General Public License for more details.
9861 *
9862 * You should have received a copy of the GNU General Public License
9863 * along with this program; if not, see <http://www.gnu.org/licenses/>.
9864 *
9865 * Note: This code is heavily based on the GNU MP Library.
9866 * Actually it's the same code with only minor changes in the
9867 * way the data is stored; this is to support the abstraction
9868 * of an optional secure memory allocation which may be used
9869 * to avoid revealing of sensitive data due to paging etc.
9870 * The GNU MP Library itself is published under the LGPL;
9871 * however I decided to publish this code under the plain GPL.
9872 */
9873
9874 #include <config.h>
9875 #include <stdio.h>
9876 #include <stdlib.h>
9877 #include "mpi-internal.h"
9878 #include "longlong.h"
9879
9880 mpi_limb_t
9881 mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
9882 mpi_limb_t s2_limb)
9883 {
9884 mpi_limb_t cy_limb;
9885 mpi_size_t j;
9886 mpi_limb_t prod_high, prod_low;
9887
9888 /* The loop counter and index J goes from -S1_SIZE to -1. This way
9889 * the loop becomes faster. */
9890 j = -s1_size;
9891
9892 /* Offset the base pointers to compensate for the negative indices. */
9893 s1_ptr -= j;
9894 res_ptr -= j;
9895
9896 cy_limb = 0;
9897 do {
9898 umul_ppmm( prod_high, prod_low, s1_ptr[j], s2_limb );
9899 prod_low += cy_limb;
9900 cy_limb = (prod_low < cy_limb?1:0) + prod_high;
9901 res_ptr[j] = prod_low;
9902 } while( ++j );
9903
9904 return cy_limb;
9905 }
9906