aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c')
-rw-r--r--[-rwxr-xr-x]linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c136
1 files changed, 68 insertions, 68 deletions
diff --git a/linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c b/linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c
index 61beea3..f48c12c 100755..100644
--- a/linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c
+++ b/linden/indra/libgcrypt/libgcrypt-1.2.2/mpi/generic/mpih-lshift.c
@@ -1,68 +1,68 @@
1/* mpi-lshift.c - MPI helper functions 1/* mpi-lshift.c - MPI helper functions
2 * Copyright (C) 1994, 1996, 1998, 2001, 2002 Free Software Foundation, Inc. 2 * Copyright (C) 1994, 1996, 1998, 2001, 2002 Free Software Foundation, Inc.
3 * 3 *
4 * This file is part of Libgcrypt. 4 * This file is part of Libgcrypt.
5 * 5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify 6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as 7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of 8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version. 9 * the License, or (at your option) any later version.
10 * 10 *
11 * Libgcrypt is distributed in the hope that it will be useful, 11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details. 14 * GNU Lesser General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Lesser General Public 16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, write to the Free Software 17 * License along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 * 19 *
20 * Note: This code is heavily based on the GNU MP Library. 20 * Note: This code is heavily based on the GNU MP Library.
21 * Actually it's the same code with only minor changes in the 21 * Actually it's the same code with only minor changes in the
22 * way the data is stored; this is to support the abstraction 22 * way the data is stored; this is to support the abstraction
23 * of an optional secure memory allocation which may be used 23 * of an optional secure memory allocation which may be used
24 * to avoid revealing of sensitive data due to paging etc. 24 * to avoid revealing of sensitive data due to paging etc.
25 */ 25 */
26 26
27#include <config.h> 27#include <config.h>
28#include <stdio.h> 28#include <stdio.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include "mpi-internal.h" 30#include "mpi-internal.h"
31 31
32/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left 32/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left
33 * and store the USIZE least significant digits of the result at WP. 33 * and store the USIZE least significant digits of the result at WP.
34 * Return the bits shifted out from the most significant digit. 34 * Return the bits shifted out from the most significant digit.
35 * 35 *
36 * Argument constraints: 36 * Argument constraints:
37 * 1. 0 < CNT < BITS_PER_MP_LIMB 37 * 1. 0 < CNT < BITS_PER_MP_LIMB
38 * 2. If the result is to be written over the input, WP must be >= UP. 38 * 2. If the result is to be written over the input, WP must be >= UP.
39 */ 39 */
40 40
41mpi_limb_t 41mpi_limb_t
42_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, 42_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
43 unsigned int cnt) 43 unsigned int cnt)
44{ 44{
45 mpi_limb_t high_limb, low_limb; 45 mpi_limb_t high_limb, low_limb;
46 unsigned sh_1, sh_2; 46 unsigned sh_1, sh_2;
47 mpi_size_t i; 47 mpi_size_t i;
48 mpi_limb_t retval; 48 mpi_limb_t retval;
49 49
50 sh_1 = cnt; 50 sh_1 = cnt;
51 wp += 1; 51 wp += 1;
52 sh_2 = BITS_PER_MPI_LIMB - sh_1; 52 sh_2 = BITS_PER_MPI_LIMB - sh_1;
53 i = usize - 1; 53 i = usize - 1;
54 low_limb = up[i]; 54 low_limb = up[i];
55 retval = low_limb >> sh_2; 55 retval = low_limb >> sh_2;
56 high_limb = low_limb; 56 high_limb = low_limb;
57 while ( --i >= 0 ) 57 while ( --i >= 0 )
58 { 58 {
59 low_limb = up[i]; 59 low_limb = up[i];
60 wp[i] = (high_limb << sh_1) | (low_limb >> sh_2); 60 wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
61 high_limb = low_limb; 61 high_limb = low_limb;
62 } 62 }
63 wp[i] = high_limb << sh_1; 63 wp[i] = high_limb << sh_1;
64 64
65 return retval; 65 return retval;
66} 66}
67 67
68 68