[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] 50/70: - not working test
From: |
gnunet |
Subject: |
[gnunet] 50/70: - not working test |
Date: |
Wed, 31 Aug 2022 18:00:44 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 9df46666fb7bf75fc833b2aaa5fee99425be3a19
Author: Tristan Schwieren <tristan.schwieren@tum.de>
AuthorDate: Wed May 25 16:55:58 2022 +0200
- not working test
---
src/reclaim/Makefile.am | 6 +++++-
src/reclaim/did_helper.c | 27 +++++++++++++++++++-----
src/reclaim/did_helper.h | 12 +++++++----
src/reclaim/gnunet-did.c | 17 ++++++++-------
src/reclaim/test_did_helper.c | 49 +++++++++++++++++++++++++++++++++++++++----
5 files changed, 89 insertions(+), 22 deletions(-)
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am
index 912f4a92f..32631427b 100644
--- a/src/reclaim/Makefile.am
+++ b/src/reclaim/Makefile.am
@@ -209,7 +209,11 @@ test_w3c_ed25519_2020_LDADD = \
test_did_helper_SOURCES = \
test_did_helper.c
test_did_helper_LDADD = \
- $(top_builddir)/src/util/libgnunetutil.la
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la
check_SCRIPTS = \
test_reclaim_attribute.sh \
diff --git a/src/reclaim/did_helper.c b/src/reclaim/did_helper.c
index ad02d96b5..707cee85e 100644
--- a/src/reclaim/did_helper.c
+++ b/src/reclaim/did_helper.c
@@ -19,7 +19,7 @@
*/
/**
- * @file reclaim/oidc_helper.h
+ * @file reclaim/did_helper.c
* @brief helper library for DID related functions
* @author Tristan Schwieren
*/
@@ -72,10 +72,27 @@ GNUNET_DID_identity_to_did (struct GNUNET_IDENTITY_Ego *ego)
/**
* @brief Return the public key of a DID
*/
-struct GNUNET_IDENTITY_PublicKey *
-GNUNET_DID_did_to_pkey (char *did)
+int
+GNUNET_DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey)
{
- return NULL;
+ /* FIXME-MSC: I suggest introducing a
+ * #define MAX_DID_LENGTH <something>
+ * here and use it for parsing
+ */
+ char pkey_str[MAX_DID_SPECIFIC_IDENTIFIER_LENGTH];
+
+ if ((1 != (sscanf (did,
+ GNUNET_DID_METHOD_PREFIX "%"
+ STR (MAX_DID_SPECIFIC_IDENTIFIER_LENGTH)
+ "s", pkey_str))) ||
+ (GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not decode given DID: %s\n",
+ did);
+ return 1;
+ }
+
+ return 0;
}
/**
@@ -100,7 +117,7 @@ GNUNET_DID_key_covert_multibase_base64_to_gnunet (char
*pkey_str)
* @brief Convert GNUNET key to a base 64 encoded public key
*/
char *
-GNUNET_DID_key_covert_gnunet_multibase_to_base64 (struct
+GNUNET_DID_key_covert_gnunet_to_multibase_base64 (struct
GNUNET_IDENTITY_PublicKey *
pkey)
{
diff --git a/src/reclaim/did_helper.h b/src/reclaim/did_helper.h
index bc4db239e..98b385b4c 100644
--- a/src/reclaim/did_helper.h
+++ b/src/reclaim/did_helper.h
@@ -19,12 +19,16 @@
*/
/**
- * @file reclaim/oidc_helper.h
+ * @file reclaim/did_helper.h
* @brief helper library for DID related functions
* @author Tristan Schwieren
*/
+#define STR_INDIR(x) #x
+#define STR(x) STR_INDIR(x)
+
#define GNUNET_DID_METHOD_PREFIX "did:reclaim:"
+#define MAX_DID_SPECIFIC_IDENTIFIER_LENGTH 59
/**
* @brief Return a DID for a given GNUNET public key
@@ -44,8 +48,8 @@ GNUNET_DID_identity_to_did(struct GNUNET_IDENTITY_Ego *ego);
/**
* @brief Return the public key of a DID
*/
-struct GNUNET_IDENTITY_PublicKey *
-GNUNET_DID_did_to_pkey(char *did);
+int
+GNUNET_DID_did_to_pkey (char *did, struct GNUNET_IDENTITY_PublicKey *pkey);
/**
* @brief Return the GNUNET EGO of a DID
@@ -63,7 +67,7 @@ GNUNET_DID_key_covert_multibase_base64_to_gnunet(char *);
* @brief Convert GNUNET key to a base 64 encoded public key
*/
char *
-GNUNET_DID_key_covert_gnunet_multibase_to_base64(struct
GNUNET_IDENTITY_PublicKey *);
+GNUNET_DID_key_covert_gnunet_to_multibase_base64(struct
GNUNET_IDENTITY_PublicKey *);
/**
* @brief Generate the default DID document for a GNUNET public key
diff --git a/src/reclaim/gnunet-did.c b/src/reclaim/gnunet-did.c
index 637b403a9..435aad3fe 100644
--- a/src/reclaim/gnunet-did.c
+++ b/src/reclaim/gnunet-did.c
@@ -211,10 +211,10 @@ get_pkey_from_attr_did (struct GNUNET_IDENTITY_PublicKey
*pkey)
*/
char pkey_str[59];
- if ((1 != (sscanf (did, GNUNET_DID_METHOD_PREFIX"%58s", pkey_str))) ||
+ if ((1 != (sscanf (did, GNUNET_DID_METHOD_PREFIX "%58s", pkey_str))) ||
(GNUNET_OK != GNUNET_IDENTITY_public_key_from_string (pkey_str, pkey)))
{
- fprintf (stderr, _("Invalid DID `%s'\n"), pkey_str);
+ fprintf (stderr, _ ("Invalid DID `%s'\n"), pkey_str);
GNUNET_SCHEDULER_add_now (cleanup, NULL);
ret = 1;
return;
@@ -279,7 +279,8 @@ resolve_did_document ()
get_pkey_from_attr_did (&pkey);
- GNUNET_GNS_lookup (gns_handle, GNUNET_GNS_EMPTY_LABEL_AT, &pkey,
GNUNET_DNSPARSER_TYPE_TXT,
+ GNUNET_GNS_lookup (gns_handle, GNUNET_GNS_EMPTY_LABEL_AT, &pkey,
+ GNUNET_DNSPARSER_TYPE_TXT,
GNUNET_GNS_LO_DEFAULT, &print_did_document, NULL);
}
@@ -328,7 +329,8 @@ remove_did_document_namestore_cb (void *cls, int32_t
success, const char *emgs)
ret = 0;
return;
}
- } else {
+ }
+ else {
printf ("Something went wrong when deleting the DID Document\n");
if (emgs != NULL)
@@ -433,7 +435,7 @@ create_did_store (char *didd_str, struct
GNUNET_IDENTITY_Ego *ego)
GNUNET_NAMESTORE_records_store (namestore_handle,
skey,
GNUNET_GNS_EMPTY_LABEL_AT,
- 1, //FIXME what if
GNUNET_GNS_EMPTY_LABEL_AT has records
+ 1, // FIXME what if
GNUNET_GNS_EMPTY_LABEL_AT has records
&record_data,
&create_did_store_cb,
NULL);
@@ -642,7 +644,7 @@ process_dids (void *cls, struct GNUNET_IDENTITY_Ego *ego,
(0 == strncmp (name, egoname, strlen (egoname))) &&
(1 != ego_exists))
{
- fprintf(stderr, "%s already exists!\n", egoname);
+ fprintf (stderr, "%s already exists!\n", egoname);
ego_exists = 1;
return;
}
@@ -761,8 +763,7 @@ main (int argc, char *const argv[])
if (GNUNET_OK != GNUNET_PROGRAM_run (argc,
argv,
"gnunet-did",
- _ (
- "Manage Decentralized Identities
(DIDs)"),
+ "Manage Decentralized Identities
(DIDs)",
options,
&run,
NULL))
diff --git a/src/reclaim/test_did_helper.c b/src/reclaim/test_did_helper.c
index 2c3ce0dce..ddc967b6c 100644
--- a/src/reclaim/test_did_helper.c
+++ b/src/reclaim/test_did_helper.c
@@ -25,11 +25,52 @@
*/
#include "platform.h"
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_namestore_service.h"
+#include "gnunet_gns_service.h"
+#include "gnunet_gnsrecord_lib.h"
+#include "did_helper.h"
+
+static char test_privkey[32] = {
+ 0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c,
+ 0xfa, 0xb9, 0xd5, 0xa3, 0xba, 0xac, 0xc9, 0xb2,
+ 0xa5, 0xfe, 0xbe, 0x4b, 0x14, 0x9f, 0x12, 0x6b,
+ 0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17
+};
+
+
+int
+test_GNUNET_DID_pkey_to_did ()
+{
+ struct GNUNET_IDENTITY_PrivateKey skey;
+ struct GNUNET_IDENTITY_PublicKey pkey;
+ char *str_pkey;
+
+ skey.type = GNUNET_GNSRECORD_TYPE_EDKEY;
+ memcpy (&(skey.eddsa_key), test_privkey, sizeof(struct
GNUNET_CRYPTO_EddsaPrivateKey));
+
+ GNUNET_IDENTITY_key_get_public (&skey, &pkey);
+
+ str_pkey = GNUNET_IDENTITY_public_key_to_string (&pkey);
+
+ // TODO: Give to function, compare to real DID
+ return 0;
+}
+
+int
+test_GNUNET_DID_did_to_pkey ();
+
+int
+test_GNUNET_DID_key_covert_multibase_base64_to_gnunet ();
+
+int
+test_GNUNET_DID_key_covert_gnunet_to_multibase_base64 ();
int
-main()
+main ()
{
- GNUNET_assert(0 == 1);
- return 0;
+ test_GNUNET_DID_pkey_to_did();
+
+ GNUNET_assert (0 == 0);
+ return 0;
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [gnunet] 52/70: - working did lib and 1. test for did helper, (continued)
- [gnunet] 52/70: - working did lib and 1. test for did helper, gnunet, 2022/08/31
- [gnunet] 62/70: - refactored DID create, gnunet, 2022/08/31
- [gnunet] 49/70: - init did test, gnunet, 2022/08/31
- [gnunet] 42/70: -did mulitbase key and assert method for VCs, gnunet, 2022/08/31
- [gnunet] 18/70: -did working replace, generalized remove, refactor, gnunet, 2022/08/31
- [gnunet] 21/70: -did key check, gnunet, 2022/08/31
- [gnunet] 33/70: -add test for w3c-ed25519-2020, gnunet, 2022/08/31
- [gnunet] 35/70: -test against mb b64, gnunet, 2022/08/31
- [gnunet] 38/70: -did working replace, generalized remove, refactor, gnunet, 2022/08/31
- [gnunet] 39/70: -did expiration time fix, gnunet, 2022/08/31
- [gnunet] 50/70: - not working test,
gnunet <=
- [gnunet] 47/70: -move to reclaim, gnunet, 2022/08/31
- [gnunet] 44/70: -add comments, gnunet, 2022/08/31
- [gnunet] 43/70: -mergefix, gnunet, 2022/08/31
- [gnunet] 36/70: -did not working remove abstraction, gnunet, 2022/08/31
- [gnunet] 45/70: fix bugs, gnunet, 2022/08/31
- [gnunet] 66/70: - DID lib; renamed vars and moved a free, gnunet, 2022/08/31
- [gnunet] 63/70: - remove static variable from did_core, gnunet, 2022/08/31
- [gnunet] 55/70: - finished DID helper with tests, gnunet, 2022/08/31
- [gnunet] 60/70: - started with DID lib create func, gnunet, 2022/08/31
- [gnunet] 54/70: - default did document test without multibase, gnunet, 2022/08/31