summaryrefslogtreecommitdiff
path: root/mpi/mpi-bit.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-07-02 09:50:57 +0000
committerWerner Koch <wk@gnupg.org>1999-07-02 09:50:57 +0000
commit745415540374611ab1a944a1ee376c814adb9318 (patch)
tree5d426a7623f04c9ceaa97f86b6544e9ae125e41e /mpi/mpi-bit.c
parent26a58078810c1d71303554d0eb3e7912c060a548 (diff)
downloadlibgcrypt-745415540374611ab1a944a1ee376c814adb9318.tar.gz
See ChangeLog: Fri Jul 2 11:45:54 CEST 1999 Werner Koch
Diffstat (limited to 'mpi/mpi-bit.c')
-rw-r--r--mpi/mpi-bit.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c
index 00aa5d08..f1eff863 100644
--- a/mpi/mpi-bit.c
+++ b/mpi/mpi-bit.c
@@ -212,3 +212,51 @@ mpi_rshift( MPI x, MPI a, unsigned n )
x->nlimbs = xsize;
}
+
+/****************
+ * Shift A by COUNT limbs to the left
+ * This is used only within the MPI library
+ */
+void
+mpi_lshift_limbs( MPI a, unsigned int count )
+{
+ mpi_ptr_t ap = a->d;
+ int n = a->nlimbs;
+ int i;
+
+ if( !count || !n )
+ return;
+
+ RESIZE_IF_NEEDED( a, n+count );
+
+ for( i = n-1; i >= 0; i-- )
+ ap[i+count] = ap[i];
+ for(i=0; i < count; i++ )
+ ap[i] = 0;
+ a->nlimbs += count;
+}
+
+
+/****************
+ * Shift A by COUNT limbs to the right
+ * This is used only within the MPI library
+ */
+void
+mpi_rshift_limbs( MPI a, unsigned int count )
+{
+ mpi_ptr_t ap = a->d;
+ mpi_size_t n = a->nlimbs;
+ unsigned int i;
+
+ if( count >= n ) {
+ a->nlimbs = 0;
+ return;
+ }
+
+ for( i = 0; i < n - count; i++ )
+ ap[i] = ap[i+count];
+ ap[i] = 0;
+ a->nlimbs -= count;
+}
+
+