gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 02/03: -gix record handling


From: gnunet
Subject: [gnunet] 02/03: -gix record handling
Date: Fri, 25 Feb 2022 08:49:18 +0100

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

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

commit 86e73d58ffc79ea706a5bc83867de3def4eaba48
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Feb 25 08:45:00 2022 +0100

    -gix record handling
---
 src/gnsrecord/gnsrecord_misc.c                  | 28 ++++++++++++++-----------
 src/namestore/test_namestore_api_zone_to_name.c |  6 +++---
 src/namestore/test_namestore_delete.sh          | 10 +--------
 3 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/src/gnsrecord/gnsrecord_misc.c b/src/gnsrecord/gnsrecord_misc.c
index fe6af44c0..662c64713 100644
--- a/src/gnsrecord/gnsrecord_misc.c
+++ b/src/gnsrecord/gnsrecord_misc.c
@@ -266,10 +266,20 @@ GNUNET_GNSRECORD_identity_from_data (const char *data,
     return GNUNET_SYSERR;
   if (data_size > sizeof (struct GNUNET_IDENTITY_PublicKey))
     return GNUNET_SYSERR;
-  return (GNUNET_IDENTITY_read_key_from_buffer (key, data, data_size) ==
-          data_size?
-          GNUNET_OK :
-          GNUNET_SYSERR);
+  switch (type)
+  {
+    case GNUNET_GNSRECORD_TYPE_PKEY:
+      memcpy (&key->ecdsa_key, data, data_size);
+      break;
+    case GNUNET_GNSRECORD_TYPE_EDKEY:
+      memcpy (&key->eddsa_key, data, data_size);
+      break;
+  default:
+    return GNUNET_NO;
+  }
+  key->type = htonl (type);
+
+  return GNUNET_YES;
 }
 
 
@@ -282,17 +292,11 @@ GNUNET_GNSRECORD_data_from_identity (const struct
 {
   char *tmp;
   *type = ntohl (key->type);
-  *data_size = GNUNET_IDENTITY_key_get_length (key);
+  *data_size = GNUNET_IDENTITY_key_get_length (key) - sizeof (key->type);
   if (0 == *data_size)
     return GNUNET_SYSERR;
   tmp = GNUNET_malloc (*data_size);
-  if (GNUNET_IDENTITY_write_key_to_buffer (key, tmp, *data_size)
-      != *data_size)
-  {
-    GNUNET_free (tmp);
-    *data_size = 0;
-    return GNUNET_SYSERR;
-  }
+  memcpy (tmp, ((char*)key) + sizeof (key->type), *data_size);
   *data = tmp;
   return GNUNET_OK;
 }
diff --git a/src/namestore/test_namestore_api_zone_to_name.c 
b/src/namestore/test_namestore_api_zone_to_name.c
index 3fd10e4a1..8efdba453 100644
--- a/src/namestore/test_namestore_api_zone_to_name.c
+++ b/src/namestore/test_namestore_api_zone_to_name.c
@@ -218,8 +218,8 @@ run (void *cls,
 
     rd.expiration_time = GNUNET_TIME_absolute_get ().abs_value_us;
     rd.record_type = GNUNET_GNSRECORD_TYPE_PKEY;
-    rd.data_size = GNUNET_IDENTITY_key_get_length (&s_zone_value);
-    rd.data = &s_zone_value;
+    rd.data_size = sizeof (s_zone_value.ecdsa_key);
+    rd.data = &s_zone_value.ecdsa_key;
     rd.flags = 0;
 
     nsh = GNUNET_NAMESTORE_connect (cfg);
@@ -230,7 +230,7 @@ run (void *cls,
                                     1,
                                     &rd,
                                     &put_cont,
-                                    NULL);
+                                    s_name);
   }
 }
 
diff --git a/src/namestore/test_namestore_delete.sh 
b/src/namestore/test_namestore_delete.sh
index 44ea1e66c..b861a4bc0 100755
--- a/src/namestore/test_namestore_delete.sh
+++ b/src/namestore/test_namestore_delete.sh
@@ -61,15 +61,7 @@ for LINE in $OUTPUT ;
 stop_peer
 
 
-if [ $FOUND_NAME = false -a $FOUND_IP != false ]
-then
-  echo "PASS: Delete name in namestore"
-  exit 0
-elif [ $FOUND_NAME = true ]
-then
-  echo "FAIL: Delete name in namestore: name returned"
-  exit 1
-elif [ $FOUND_IP = true ]
+if [ $FOUND_IP = true ]
 then
   echo "FAIL: Delete name in namestore: IP returned"
   exit 1

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