[git] GCRYPT - branch, master, updated. libgcrypt-1.7.3-101-gee3a74f

by Werner Koch cvs at cvs.gnupg.org
Fri Jun 16 12:35:33 CEST 2017


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  ee3a74f5539cbc5182ce089994e37c16ce612149 (commit)
      from  8f6082e95f30c1ba68d2de23da90146f87f0c66c (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 ee3a74f5539cbc5182ce089994e37c16ce612149
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Jun 16 12:31:11 2017 +0200

    random: Allow building rndjent.c with stats collecting enabled.
    
    * random/rndjent.c: Change license to the one used by jitterentropy.h.
    (jent_init_statistic): New.
    (jent_bit_count): New.
    (jent_statistic_copy_stat): new.
    (jent_calc_statistic): New.
    --
    
    New code taken from Stephan's jitterentropy-stat.c.  This does now
    build with CONFIG_CRYPTO_CPU_JITTERENTROPY_STAT defined; not sure
    whether this is already useful.  Changed the license due to the new
    code.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/LICENSES b/LICENSES
index 9c0267e..f6733a6 100644
--- a/LICENSES
+++ b/LICENSES
@@ -56,9 +56,9 @@ with any binary distributions derived from the GNU C Library.
 
 
   For files:
-  - random/jitterentropy-base-user.h
   - random/jitterentropy-base.c
   - random/jitterentropy.h
+  - random/rndjent.c (plus common Libgcrypt copyright holders)
 
 #+begin_quote
  * Copyright Stephan Mueller <smueller at chronox.de>, 2013
diff --git a/random/rndjent.c b/random/rndjent.c
index f997850..99318b4 100644
--- a/random/rndjent.c
+++ b/random/rndjent.c
@@ -1,21 +1,39 @@
 /* rndjent.c  - Driver for the jitterentropy module.
  * Copyright (C) 2017 g10 Code GmbH
  * Copyright (C) 2017 Bundesamt für Sicherheit in der Informationstechnik
+ * Copyright (C) 2013 Stephan Mueller <smueller at chronox.de>
  *
- * This file is part of Libgcrypt.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
  *
- * Libgcrypt is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU General Public License, in which case the provisions of the GPL are
+ * required INSTEAD OF the above restrictions.  (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
  *
- * Libgcrypt is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
  */
 
 #include <config.h>
@@ -126,6 +144,102 @@ static unsigned long jent_rng_totalcalls;
 static unsigned long jent_rng_totalbytes;
 
 
+

+/* JENT statistic helper code.  */
+#ifdef CONFIG_CRYPTO_CPU_JITTERENTROPY_STAT
+
+static void
+jent_init_statistic (struct rand_data *rand_data)
+{
+  int i;
+  struct entropy_stat *stat = &rand_data->entropy_stat;
+
+  for (i = 0; i < 64; i++)
+    {
+      stat->bitslot[i] = 0;
+      stat->bitvar[i] = 0;
+    }
+
+  jent_get_nstime (&stat->collection_begin);
+}
+
+static void
+jent_bit_count (struct rand_data *rand_data, u64 prev_data)
+{
+  int i;
+
+  if (!rand_data->entropy_stat.enable_bit_test)
+    return;
+
+  for (i = 0; i < 64; i++)
+    {
+      /* collect the count of set bits per bit position in the
+       * current ->data field */
+      rand_data->entropy_stat.bitslot[i] += (rand_data->data & 1<<i) ? 1:0;
+
+      /* collect the count of bit changes between the current
+       * and the previous random data value per bit position */
+      if ((rand_data->data & 1<<i) != (prev_data & 1<<i))
+        rand_data->entropy_stat.bitvar[i] += 1;
+    }
+}
+
+
+static void
+jent_statistic_copy_stat (struct entropy_stat *src, struct entropy_stat *dst)
+{
+  /* not copying bitslot and bitvar as they are not needed for
+   * statistic printout */
+  dst->collection_begin = src->collection_begin;
+  dst->collection_end	= src->collection_end;
+  dst->old_delta	= src->old_delta;
+  dst->setbits		= src->setbits;
+  dst->varbits		= src->varbits;
+  dst->obsbits		= src->obsbits;
+  dst->collection_loop_cnt= src->collection_loop_cnt;
+}
+
+
+/*
+ * Assessment of statistical behavior of the generated output and returning
+ * the information to the caller by filling the target value.
+ *
+ * Details about the bit statistics are given in chapter 4 of the doc.
+ * Chapter 5 documents the timer analysis and the resulting entropy.
+ */
+static void
+jent_calc_statistic (struct rand_data *rand_data,
+                     struct entropy_stat *target, unsigned int loop_cnt)
+{
+  int i;
+  struct entropy_stat *stat = &rand_data->entropy_stat;
+
+  jent_get_nstime(&stat->collection_end);
+
+  stat->collection_loop_cnt = loop_cnt;
+
+  stat->setbits = 0;
+  stat->varbits = 0;
+  stat->obsbits = 0;
+
+  for (i = 0; i < DATA_SIZE_BITS; i++)
+    {
+      stat->setbits += stat->bitslot[i];
+      stat->varbits += stat->bitvar[i];
+
+      /* This is the sum of set bits in the current observation
+       * of the random data. */
+      stat->obsbits += (rand_data->data & 1<<i) ? 1:0;
+    }
+
+  jent_statistic_copy_stat(stat, target);
+
+  stat->old_delta = (stat->collection_end - stat->collection_begin);
+}
+
+#endif /*CONFIG_CRYPTO_CPU_JITTERENTROPY_STAT*/
+
+
 /* Acquire the jent_rng_lock.  */
 static void
 lock_rng (void)

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

Summary of changes:
 LICENSES         |   2 +-
 random/rndjent.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 127 insertions(+), 13 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