gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31858 - gnunet/src/util


From: gnunet
Subject: [GNUnet-SVN] r31858 - gnunet/src/util
Date: Thu, 9 Jan 2014 13:49:44 +0100

Author: grothoff
Date: 2014-01-09 13:49:44 +0100 (Thu, 09 Jan 2014)
New Revision: 31858

Modified:
   gnunet/src/util/crypto_hash.c
   gnunet/src/util/crypto_hkdf.c
Log:
-revert 'optimization' that broke test_crypto_hkdf

Modified: gnunet/src/util/crypto_hash.c
===================================================================
--- gnunet/src/util/crypto_hash.c       2014-01-09 12:23:08 UTC (rev 31857)
+++ gnunet/src/util/crypto_hash.c       2014-01-09 12:49:44 UTC (rev 31858)
@@ -36,12 +36,14 @@
 /**
  * Hash block of given size.
  *
- * @param block the data to GNUNET_CRYPTO_hash, length is given as a second 
argument
- * @param size the length of the data to GNUNET_CRYPTO_hash
+ * @param block the data to #GNUNET_CRYPTO_hash, length is given as a second 
argument
+ * @param size the length of the data to #GNUNET_CRYPTO_hash in @a block
  * @param ret pointer to where to write the hashcode
  */
 void
-GNUNET_CRYPTO_hash (const void *block, size_t size, struct GNUNET_HashCode * 
ret)
+GNUNET_CRYPTO_hash (const void *block,
+                    size_t size,
+                    struct GNUNET_HashCode *ret)
 {
   gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size);
 }

Modified: gnunet/src/util/crypto_hkdf.c
===================================================================
--- gnunet/src/util/crypto_hkdf.c       2014-01-09 12:23:08 UTC (rev 31857)
+++ gnunet/src/util/crypto_hkdf.c       2014-01-09 12:49:44 UTC (rev 31858)
@@ -87,11 +87,11 @@
  * @brief Generate pseudo-random key
  * @param mac gcrypt HMAC handle
  * @param xts salt
- * @param xts_len length of the salt
+ * @param xts_len length of the @a xts salt
  * @param skm source key material
- * @param skm_len length of skm
+ * @param skm_len length of @a skm
  * @param prk result buffer (allocated by caller; at least gcry_md_dlen() 
bytes)
- * @return GNUNET_YES on success
+ * @return #GNUNET_YES on success
  */
 static int
 getPRK (gcry_md_hd_t mac, const void *xts, size_t xts_len, const void *skm,
@@ -131,9 +131,9 @@
  * @param xtr_algo hash algorithm for the extraction phase, GCRY_MD_...
  * @param prf_algo hash algorithm for the expansion phase, GCRY_MD_...
  * @param xts salt
- * @param xts_len length of xts
+ * @param xts_len length of @a xts
  * @param skm source key material
- * @param skm_len length of skm
+ * @param skm_len length of @a skm
  * @param argp va_list of void * & size_t pairs for context chunks
  * @return #GNUNET_YES on success
  */
@@ -142,9 +142,8 @@
                       const void *xts, size_t xts_len, const void *skm,
                       size_t skm_len, va_list argp)
 {
-  static int once;
-  static gcry_md_hd_t xtr;
-  static gcry_md_hd_t prf;
+  gcry_md_hd_t xtr;
+  gcry_md_hd_t prf;
   const void *hc;
   unsigned long i;
   unsigned long t;
@@ -158,26 +157,15 @@
 
   if (0 == k)
     return GNUNET_SYSERR;
-  if (! once)
+  if (GPG_ERR_NO_ERROR !=
+      gcry_md_open (&xtr, xtr_algo, GCRY_MD_FLAG_HMAC))
+    return GNUNET_SYSERR;
+  if (GPG_ERR_NO_ERROR !=
+      gcry_md_open (&prf, prf_algo, GCRY_MD_FLAG_HMAC))
   {
-    if (GPG_ERR_NO_ERROR !=
-        gcry_md_open (&xtr, xtr_algo, GCRY_MD_FLAG_HMAC))
-      return GNUNET_SYSERR;
-
-    if (GPG_ERR_NO_ERROR !=
-        gcry_md_open (&prf, prf_algo, GCRY_MD_FLAG_HMAC))
-    {
-      gcry_md_close (xtr);
-      return GNUNET_SYSERR;
-    }
-    once = 1;
+    gcry_md_close (xtr);
+    return GNUNET_SYSERR;
   }
-  else
-  {
-    gcry_md_reset (xtr);
-    gcry_md_reset (prf);
-  }
-
   va_copy (args, argp);
 
   ctx_len = 0;
@@ -275,6 +263,8 @@
 hkdf_error:
   ret = GNUNET_SYSERR;
 hkdf_ok:
+  gcry_md_close (xtr);
+  gcry_md_close (prf);
   return ret;
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]