gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: crypto: fix elligator warnings


From: gnunet
Subject: [gnunet] branch master updated: crypto: fix elligator warnings
Date: Fri, 01 Mar 2024 10:14:50 +0100

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

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new abb648177 crypto: fix elligator warnings
abb648177 is described below

commit abb648177bd5ecbcf8c0c6ce9be353a43fbf5b76
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Mar 1 10:14:44 2024 +0100

    crypto: fix elligator warnings
---
 contrib/gana                         |  2 +-
 contrib/handbook                     |  2 +-
 src/include/gnunet_crypto_lib.h      | 99 ++++++++++++++++++------------------
 src/lib/util/crypto_elligator.c      | 11 ++--
 src/lib/util/test_crypto_elligator.c | 13 -----
 5 files changed, 55 insertions(+), 72 deletions(-)

diff --git a/contrib/gana b/contrib/gana
index 9eddc2cf7..72be9c845 160000
--- a/contrib/gana
+++ b/contrib/gana
@@ -1 +1 @@
-Subproject commit 9eddc2cf7b65bb43d285c75ef22fd9bc9cc7020e
+Subproject commit 72be9c8454abc39eb35e1019545ceda8ece7a6db
diff --git a/contrib/handbook b/contrib/handbook
index 5c20e0aaa..5dde35573 160000
--- a/contrib/handbook
+++ b/contrib/handbook
@@ -1 +1 @@
-Subproject commit 5c20e0aaa95c7cebc225d02231221d18fdcbdb53
+Subproject commit 5dde35573cfc8e22bbf2810fb5bacc22726ac74c
diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h
index 5425a18dd..4580f795d 100644
--- a/src/include/gnunet_crypto_lib.h
+++ b/src/include/gnunet_crypto_lib.h
@@ -973,7 +973,7 @@ GNUNET_CRYPTO_hash_from_string2 (const char *enc,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if result has the wrong 
encoding
  */
 #define GNUNET_CRYPTO_hash_from_string(enc, result) \
-  GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
+        GNUNET_CRYPTO_hash_from_string2 (enc, strlen (enc), result)
 
 
 /**
@@ -2215,15 +2215,15 @@ GNUNET_CRYPTO_eddsa_sign_ (
  * @param[out] sig where to write the signature
  */
 #define GNUNET_CRYPTO_eddsa_sign(priv,ps,sig) do {                 \
-    /* check size is set correctly */                              \
-    GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps));    \
-    /* check 'ps' begins with the purpose */                       \
-    GNUNET_static_assert (((void*) (ps)) ==                        \
-                          ((void*) &(ps)->purpose));               \
-    GNUNET_assert (GNUNET_OK ==                                    \
-                   GNUNET_CRYPTO_eddsa_sign_ (priv,                \
-                                              &(ps)->purpose,      \
-                                              sig));               \
+          /* check size is set correctly */                              \
+          GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*ps));    \
+          /* check 'ps' begins with the purpose */                       \
+          GNUNET_static_assert (((void*) (ps)) ==                        \
+                                ((void*) &(ps)->purpose));               \
+          GNUNET_assert (GNUNET_OK ==                                    \
+                         GNUNET_CRYPTO_eddsa_sign_ (priv,                \
+                                                    &(ps)->purpose,      \
+                                                    sig));               \
 } while (0)
 
 
@@ -2277,15 +2277,15 @@ GNUNET_CRYPTO_eddsa_sign_raw (
  * @param[out] sig where to write the signature
  */
 #define GNUNET_CRYPTO_ecdsa_sign(priv,ps,sig) do {                 \
-    /* check size is set correctly */                              \
-    GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));  \
-    /* check 'ps' begins with the purpose */                       \
-    GNUNET_static_assert (((void*) (ps)) ==                        \
-                          ((void*) &(ps)->purpose));               \
-    GNUNET_assert (GNUNET_OK ==                                    \
-                   GNUNET_CRYPTO_ecdsa_sign_ (priv,                \
-                                              &(ps)->purpose,      \
-                                              sig));               \
+          /* check size is set correctly */                              \
+          GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));  \
+          /* check 'ps' begins with the purpose */                       \
+          GNUNET_static_assert (((void*) (ps)) ==                        \
+                                ((void*) &(ps)->purpose));               \
+          GNUNET_assert (GNUNET_OK ==                                    \
+                         GNUNET_CRYPTO_ecdsa_sign_ (priv,                \
+                                                    &(ps)->purpose,      \
+                                                    sig));               \
 } while (0)
 
 /**
@@ -2324,15 +2324,15 @@ GNUNET_CRYPTO_edx25519_sign_ (
  * @param[out] sig where to write the signature
  */
 #define GNUNET_CRYPTO_edx25519_sign(priv,ps,sig) do {              \
-    /* check size is set correctly */                              \
-    GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));  \
-    /* check 'ps' begins with the purpose */                       \
-    GNUNET_static_assert (((void*) (ps)) ==                        \
-                          ((void*) &(ps)->purpose));               \
-    GNUNET_assert (GNUNET_OK ==                                    \
-                   GNUNET_CRYPTO_edx25519_sign_ (priv,             \
-                                                 &(ps)->purpose,   \
-                                                 sig));            \
+          /* check size is set correctly */                              \
+          GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));  \
+          /* check 'ps' begins with the purpose */                       \
+          GNUNET_static_assert (((void*) (ps)) ==                        \
+                                ((void*) &(ps)->purpose));               \
+          GNUNET_assert (GNUNET_OK ==                                    \
+                         GNUNET_CRYPTO_edx25519_sign_ (priv,             \
+                                                       &(ps)->purpose,   \
+                                                       sig));            \
 } while (0)
 
 
@@ -2726,13 +2726,13 @@ GNUNET_CRYPTO_ecdhe_elligator_initialize (void);
  * @param pk private key for generating valid public key
  */
 int
-  GNUNET_CRYPTO_ecdhe_elligator_generate_public_key (unsigned char
-                                                     pub[
-                                                       
crypto_scalarmult_SCALARBYTES
-                                                     ],
-                                                     struct
-                                                     
GNUNET_CRYPTO_EcdhePrivateKey
-                                                     *pk);
+GNUNET_CRYPTO_ecdhe_elligator_generate_public_key (unsigned char
+                                                   pub[
+                                                     
crypto_scalarmult_SCALARBYTES
+                                                   ],
+                                                   struct
+                                                   
GNUNET_CRYPTO_EcdhePrivateKey
+                                                   *pk);
 
 
 /**
@@ -2741,13 +2741,12 @@ int
  *
  * @param repr representative of the public key
  * @param pk Curve25519 private key
+ * @return GNUNET_OK if creation successful
  */
-int
-GNUNET_CRYPTO_ecdhe_elligator_key_create (struct
-                                          GNUNET_CRYPTO_ElligatorRepresentative
-                                          *repr,
-                                          struct GNUNET_CRYPTO_EcdhePrivateKey
-                                          *pk);
+enum GNUNET_GenericReturnValue
+GNUNET_CRYPTO_ecdhe_elligator_key_create (
+  struct GNUNET_CRYPTO_ElligatorRepresentative *repr,
+  struct GNUNET_CRYPTO_EcdhePrivateKey *pk);
 
 
 /**
@@ -4233,15 +4232,15 @@ GNUNET_CRYPTO_sign_raw_ (
  * @param[out] sig where to write the signature
  */
 #define GNUNET_CRYPTO_sign(priv,ps,sig) do {                \
-    /* check size is set correctly */                                     \
-    GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));         \
-    /* check 'ps' begins with the purpose */                              \
-    GNUNET_static_assert (((void*) (ps)) ==                               \
-                          ((void*) &(ps)->purpose));                      \
-    GNUNET_assert (GNUNET_OK ==                                           \
-                   GNUNET_CRYPTO_sign_ (priv,               \
-                                        &(ps)->purpose,             \
-                                        sig));                      \
+          /* check size is set correctly */                                    
 \
+          GNUNET_assert (ntohl ((ps)->purpose.size) == sizeof (*(ps)));        
 \
+          /* check 'ps' begins with the purpose */                             
 \
+          GNUNET_static_assert (((void*) (ps)) ==                              
 \
+                                ((void*) &(ps)->purpose));                     
 \
+          GNUNET_assert (GNUNET_OK ==                                          
 \
+                         GNUNET_CRYPTO_sign_ (priv,               \
+                                              &(ps)->purpose,             \
+                                              sig));                      \
 } while (0)
 
 
diff --git a/src/lib/util/crypto_elligator.c b/src/lib/util/crypto_elligator.c
index 142c0782a..e512696a7 100644
--- a/src/lib/util/crypto_elligator.c
+++ b/src/lib/util/crypto_elligator.c
@@ -648,12 +648,9 @@ 
GNUNET_CRYPTO_ecdhe_elligator_generate_public_key_alternativ (unsigned char
 **/
 
 enum GNUNET_GenericReturnValue
-GNUNET_CRYPTO_ecdhe_elligator_key_create (struct
-                                          GNUNET_CRYPTO_ElligatorRepresentative
-                                          *
-                                          repr,
-                                          struct GNUNET_CRYPTO_EcdhePrivateKey
-                                          *pk)
+GNUNET_CRYPTO_ecdhe_elligator_key_create (
+  struct GNUNET_CRYPTO_ElligatorRepresentative  *repr,
+  struct GNUNET_CRYPTO_EcdhePrivateKey *pk)
 {
   // inverse map can fail for some public keys generated by 
GNUNET_CRYPTO_ecdhe_elligator_generate_public_key
   bool validKey = 0;
@@ -699,4 +696,4 @@ GNUNET_CRYPTO_ecdhe_elligator_key_create (struct
     repr->r[31] |= 64;
   }
   return GNUNET_OK;
-}
\ No newline at end of file
+}
diff --git a/src/lib/util/test_crypto_elligator.c 
b/src/lib/util/test_crypto_elligator.c
index fc541887d..488a296d6 100644
--- a/src/lib/util/test_crypto_elligator.c
+++ b/src/lib/util/test_crypto_elligator.c
@@ -1,23 +1,10 @@
-#include "platform.h"
 #include "gnunet_util_lib.h"
-#include "gnunet_signatures.h"
 #include <gcrypt.h>
 #include <stdio.h>
 #include <sodium.h>
 
 #define ITER 25
 
-// For debugging purposes
-static void
-printLittleEndianHex (const unsigned char *arr, size_t length)
-{
-  for (size_t i = 0; i < length; ++i)
-  {
-    printf ("%02X", arr[i]);
-  }
-  printf ("\n");
-}
-
 
 // Test vector from 
https://github.com/Kleshni/Elligator-2/blob/master/test-vectors.c
 static int

-- 
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]