[git] GCRYPT - branch, master, updated. libgcrypt-1.6.0-167-g653a9fa

by NIIBE Yutaka cvs at cvs.gnupg.org
Thu Feb 12 11:57:25 CET 2015


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  653a9fa1a3a4c35a4dc1841cb57d7e2a318f3288 (commit)
      from  40a7bdf50e19faaf106470897fed72af623adc50 (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 653a9fa1a3a4c35a4dc1841cb57d7e2a318f3288
Author: NIIBE Yutaka <gniibe at fsij.org>
Date:   Wed Feb 11 21:42:22 2015 +0900

    mpi: Add mpi_set_cond.
    
    * mpi/mpiutil.c (_gcry_mpi_set_cond): New.
    (_gcry_mpi_swap_cond): Fix types.
    * src/mpi.h (mpi_set_cond): New.

diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c
index f74dd91..fbbd3b4 100644
--- a/mpi/mpiutil.c
+++ b/mpi/mpiutil.c
@@ -482,6 +482,31 @@ _gcry_mpi_set (gcry_mpi_t w, gcry_mpi_t u)
   return w;
 }
 
+gcry_mpi_t
+_gcry_mpi_set_cond (gcry_mpi_t w, const gcry_mpi_t u, unsigned long set)
+{
+  mpi_size_t i;
+  mpi_size_t nlimbs = u->alloced;
+  mpi_limb_t mask = ((mpi_limb_t)0) - !!set;
+  mpi_limb_t x;
+
+  if (w->alloced != u->alloced)
+    log_bug ("mpi_set_cond: different sizes\n");
+
+  for (i = 0; i < nlimbs; i++)
+    {
+      x = mask & (w->d[i] ^ u->d[i]);
+      w->d[i] = w->d[i] ^ x;
+    }
+
+  x = mask & (w->nlimbs ^ u->nlimbs);
+  w->nlimbs = w->nlimbs ^ x;
+
+  x = mask & (w->sign ^ u->sign);
+  w->sign = w->sign ^ x;
+  return w;
+}
+
 
 gcry_mpi_t
 _gcry_mpi_set_ui (gcry_mpi_t w, unsigned long u)
@@ -545,10 +570,10 @@ _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;
+  mpi_size_t i;
+  mpi_size_t nlimbs = a->alloced;
+  mpi_limb_t mask = ((mpi_limb_t)0) - !!swap;
+  mpi_limb_t x;
 
   if (a->alloced != b->alloced)
     log_bug ("mpi_swap_cond: different sizes\n");
diff --git a/src/mpi.h b/src/mpi.h
index 13b5117..0d19f46 100644
--- a/src/mpi.h
+++ b/src/mpi.h
@@ -120,8 +120,11 @@ void _gcry_mpi_immutable_failed (void);
 #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))
+#define mpi_set_cond(w,u,set)  _gcry_mpi_set_cond ((w),(u),(set))
 
 void _gcry_mpi_clear( gcry_mpi_t a );
+gcry_mpi_t _gcry_mpi_set_cond (gcry_mpi_t w, const gcry_mpi_t u,
+                               unsigned long swap);
 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 );

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

Summary of changes:
 mpi/mpiutil.c | 33 +++++++++++++++++++++++++++++----
 src/mpi.h     |  3 +++
 2 files changed, 32 insertions(+), 4 deletions(-)


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