gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: - add plaintext message to revocation tv


From: gnunet
Subject: [gnunet] branch master updated: - add plaintext message to revocation tvg
Date: Tue, 01 Feb 2022 21:10:13 +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 ad6bc2037 - add plaintext message to revocation tvg
ad6bc2037 is described below

commit ad6bc2037ffee49f6df1a3ac87fa507581af2365
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue Feb 1 21:10:09 2022 +0100

    - add plaintext message to revocation tvg
---
 src/revocation/gnunet-revocation-tvg.c | 10 ++++++++++
 src/revocation/revocation.h            |  8 ++++++++
 src/revocation/revocation_api.c        | 35 ++++++++++++++++------------------
 3 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/src/revocation/gnunet-revocation-tvg.c 
b/src/revocation/gnunet-revocation-tvg.c
index f1d4b0334..3ba5b56fa 100644
--- a/src/revocation/gnunet-revocation-tvg.c
+++ b/src/revocation/gnunet-revocation-tvg.c
@@ -29,6 +29,7 @@
 #include "gnunet_revocation_service.h"
 #include "gnunet_dnsparser_lib.h"
 #include "gnunet_testing_lib.h"
+#include "revocation.h"
 #include <inttypes.h>
 
 #define TEST_EPOCHS 2
@@ -140,6 +141,15 @@ run (void *cls,
   {
     pow_passes++;
   }
+  struct GNUNET_REVOCATION_SignaturePurposePS *purp;
+  purp = REV_create_signature_message (pow);
+  fprintf (stdout, "Signed message:\n");
+  print_bytes (purp,
+               ntohl (purp->purpose.size),
+               8);
+  printf ("\n");
+  GNUNET_free (purp);
+
   exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS,
                                        TEST_EPOCHS);
   GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (pow,
diff --git a/src/revocation/revocation.h b/src/revocation/revocation.h
index c3a9c9e6b..490abf180 100644
--- a/src/revocation/revocation.h
+++ b/src/revocation/revocation.h
@@ -113,5 +113,13 @@ struct RevocationResponseMessage
 
 GNUNET_NETWORK_STRUCT_END
 
+/**
+ * Create the revocation metadata to sign for a revocation message
+ *
+ * @param pow the PoW to sign
+ * @return the signature purpose
+ */
+struct GNUNET_REVOCATION_SignaturePurposePS *
+REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow);
 
 #endif
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c
index 8f05b88fd..bc5dae021 100644
--- a/src/revocation/revocation_api.c
+++ b/src/revocation/revocation_api.c
@@ -404,19 +404,15 @@ calculate_score (const struct 
GNUNET_REVOCATION_PowCalculationHandle *ph)
   return avg;
 }
 
-
-enum GNUNET_GenericReturnValue
-check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow,
-                          const struct GNUNET_IDENTITY_PublicKey *key)
+struct GNUNET_REVOCATION_SignaturePurposePS *
+REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow)
 {
   struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
-  unsigned char *sig;
   const struct GNUNET_IDENTITY_PublicKey *pk;
   size_t ksize;
 
   pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
   ksize = GNUNET_IDENTITY_key_get_length (pk);
-
   spurp = GNUNET_malloc (sizeof (*spurp) + ksize);
   spurp->timestamp = pow->timestamp;
   spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION);
@@ -424,9 +420,19 @@ check_signature_identity (const struct 
GNUNET_REVOCATION_PowP *pow,
   GNUNET_IDENTITY_write_key_to_buffer (pk,
                                        (char*) &spurp[1],
                                        ksize);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Expected signature payload len: %u\n",
-              ntohl (spurp->purpose.size));
+  return spurp;
+}
+
+enum GNUNET_GenericReturnValue
+check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow,
+                          const struct GNUNET_IDENTITY_PublicKey *key)
+{
+  struct GNUNET_REVOCATION_SignaturePurposePS *spurp;
+  unsigned char *sig;
+  size_t ksize;
+
+  ksize = GNUNET_IDENTITY_key_get_length (key);
+  spurp = REV_create_signature_message (pow);
   sig = ((unsigned char*) &pow[1] + ksize);
   if (GNUNET_OK !=
       GNUNET_IDENTITY_signature_verify_raw_ 
(GNUNET_SIGNATURE_PURPOSE_REVOCATION,
@@ -577,16 +583,7 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey 
*key,
   pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1];
   ksize = GNUNET_IDENTITY_key_get_length (pk);
   pow->timestamp = GNUNET_TIME_absolute_hton (ts);
-  rp = GNUNET_malloc (sizeof (*rp) + ksize);
-  rp->timestamp = pow->timestamp;
-  rp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION);
-  rp->purpose.size = htonl (sizeof(*rp) + ksize);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Signature payload len: %u\n",
-              ntohl (rp->purpose.size));
-  GNUNET_IDENTITY_write_key_to_buffer (pk,
-                                       ((char*) &rp[1]),
-                                       ksize);
+  rp = REV_create_signature_message (pow);
   sig = ((char*) &pow[1]) + ksize;
   int result = GNUNET_IDENTITY_sign_raw_ (key,
                                           &rp->purpose,

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