[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-95-g4846e52

by NIIBE Yutaka cvs at cvs.gnupg.org
Wed Jul 16 10:14:46 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU crypto library".

The branch, master has been updated
       via  4846e52728970e3117f3a046ef9010be089a3ae4 (commit)
      from  1b9b00bbe41bbed32563f1102049521e703e72bd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4846e52728970e3117f3a046ef9010be089a3ae4
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Wed Jul 16 17:05:55 2014 +0900

    mpi: Add mpi_swap_cond.
    
    * mpi/mpiutil.c (_gcry_mpi_swap_cond): New.
    * src/mpi.h (mpi_swap_cond): New.
    --
    
    This is an internal function for now.

diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index fdce578..f74dd91 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -542,6 +542,34 @@ _gcry_mpi_swap (gcry_mpi_t a, gcry_mpi_t b)
 }
 
 
+void
+_gcry_mpi_swap_cond (gcry_mpi_t a, gcry_mpi_t b, unsigned long swap)
+{
+  size_t i;
+  size_t nlimbs = a->alloced;
+  unsigned long mask = 0UL - !!swap;
+  unsigned long x;
+
+  if (a->alloced != b->alloced)
+    log_bug ("mpi_swap_cond: different sizes\n");
+
+  for (i = 0; i < nlimbs; i++)
+    {
+      x = mask & (a->d[i] ^ b->d[i]);
+      a->d[i] = a->d[i] ^ x;
+      b->d[i] = b->d[i] ^ x;
+    }
+
+  x = mask & (a->nlimbs ^ b->nlimbs);
+  a->nlimbs = a->nlimbs ^ x;
+  b->nlimbs = b->nlimbs ^ x;
+
+  x = mask & (a->sign ^ b->sign);
+  a->sign = a->sign ^ x;
+  b->sign = b->sign ^ x;
+}
+
+
 gcry_mpi_t
 _gcry_mpi_new (unsigned int nbits)
 {
diff --git a/src/mpi.h b/src/mpi.h
index eb0730e..2479560 100644
--- a/src/mpi.h
+++ b/src/mpi.h
@@ -119,12 +119,14 @@ void _gcry_mpi_immutable_failed (void);
 #define mpi_alloc_set_ui(a)   _gcry_mpi_alloc_set_ui ((a))
 #define mpi_m_check(a)        _gcry_mpi_m_check ((a))
 #define mpi_const(n)          _gcry_mpi_const ((n))
+#define mpi_swap_cond(a,b,sw)  _gcry_mpi_swap_cond ((a),(b),(sw))
 
 void _gcry_mpi_clear( gcry_mpi_t a );
 gcry_mpi_t  _gcry_mpi_alloc_like( gcry_mpi_t a );
 gcry_mpi_t  _gcry_mpi_alloc_set_ui( unsigned long u);
 void _gcry_mpi_m_check( gcry_mpi_t a );
 void _gcry_mpi_swap( gcry_mpi_t a, gcry_mpi_t b);
+void _gcry_mpi_swap_cond (gcry_mpi_t a, gcry_mpi_t b, unsigned long swap);
 gcry_mpi_t _gcry_mpi_new (unsigned int nbits);
 gcry_mpi_t _gcry_mpi_snew (unsigned int nbits);
 gcry_mpi_t _gcry_mpi_set_opaque_copy (gcry_mpi_t a,

-----------------------------------------------------------------------

Summary of changes:
 mpi/mpiutil.c |   28 ++++++++++++++++++++++++++++
 src/mpi.h     |    2 ++
 2 files changed, 30 insertions(+)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list