gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 01/02: edx25519: use SHA512/256 instead of SHA256


From: gnunet
Subject: [gnunet] 01/02: edx25519: use SHA512/256 instead of SHA256
Date: Tue, 26 Apr 2022 17:14:09 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository gnunet.

commit 8d8e7d3da92e5ad4613671caed0a9a3f17e8b545
Author: Florian Dold <florian@dold.me>
AuthorDate: Tue Apr 26 17:13:36 2022 +0200

    edx25519: use SHA512/256 instead of SHA256
---
 src/util/crypto_edx25519.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/util/crypto_edx25519.c b/src/util/crypto_edx25519.c
index 2f6e12ead..775b64190 100644
--- a/src/util/crypto_edx25519.c
+++ b/src/util/crypto_edx25519.c
@@ -309,11 +309,17 @@ GNUNET_CRYPTO_edx25519_private_key_derive (
    * generation, the "R" is derived from the same derivation path as "h" and is
    * not reused. */
   {
-    crypto_hash_sha256_state hs;
-    crypto_hash_sha256_init (&hs);
-    crypto_hash_sha256_update (&hs, priv->b, sizeof(priv->b));
-    crypto_hash_sha256_update (&hs, (unsigned char*) &hc, sizeof (hc));
-    crypto_hash_sha256_final (&hs, result->b);
+    struct GNUNET_HashCode hcb;
+    struct GNUNET_HashContext *hctx;
+
+    hctx = GNUNET_CRYPTO_hash_context_start ();
+    GNUNET_CRYPTO_hash_context_read (hctx, priv->b, sizeof(priv->b));
+    GNUNET_CRYPTO_hash_context_read (hctx, (unsigned char*) &hc, sizeof (hc));
+    GNUNET_CRYPTO_hash_context_finish (hctx, &hcb);
+
+    /* Truncate result, effectively doing SHA512/256 */
+    for (size_t i = 0; i < 32; i++)
+      result->b[i] = ((unsigned char *) &hcb)[i];
   }
 
   for (size_t i = 0; i < 32; i++)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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