diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2021-12-03 16:44:17 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2021-12-21 17:17:13 +0100 |
commit | a22f99e9a4c7dfd67bf02feab55845fabd0458f4 (patch) | |
tree | 34815b1b2a032a446f1271e956e7d4062d35b8e3 | |
parent | ec74cd27358969bc1ce4bad38e072b3a7f1a0790 (diff) | |
download | gnunet-a22f99e9a4c7dfd67bf02feab55845fabd0458f4.tar.gz gnunet-a22f99e9a4c7dfd67bf02feab55845fabd0458f4.zip |
-test against mb b64
-rw-r--r-- | src/did/Makefile.am | 3 | ||||
-rw-r--r-- | src/did/test_w3c_ed25519_2020.c | 31 |
2 files changed, 21 insertions, 13 deletions
diff --git a/src/did/Makefile.am b/src/did/Makefile.am index 831197543..3f5e3f34b 100644 --- a/src/did/Makefile.am +++ b/src/did/Makefile.am | |||
@@ -30,5 +30,8 @@ test_w3c_ed25519_2020_SOURCES = \ | |||
30 | test_w3c_ed25519_2020_LDADD = \ | 30 | test_w3c_ed25519_2020_LDADD = \ |
31 | $(top_builddir)/src/util/libgnunetutil.la | 31 | $(top_builddir)/src/util/libgnunetutil.la |
32 | 32 | ||
33 | if ENABLE_TEST_RUN | ||
34 | TESTS = $(check_PROGRAMS) | ||
35 | endif | ||
33 | 36 | ||
34 | 37 | ||
diff --git a/src/did/test_w3c_ed25519_2020.c b/src/did/test_w3c_ed25519_2020.c index eeeb7cb47..e2534e6ab 100644 --- a/src/did/test_w3c_ed25519_2020.c +++ b/src/did/test_w3c_ed25519_2020.c | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_crypto_lib.h" | 29 | #include "gnunet_crypto_lib.h" |
30 | #include "gnunet_strings_lib.h" | ||
30 | 31 | ||
31 | static char test_privkey[32] = { | 32 | static char test_privkey[32] = { |
32 | 0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c, | 33 | 0x9b, 0x93, 0x7b, 0x81, 0x32, 0x2d, 0x81, 0x6c, |
@@ -35,30 +36,34 @@ static char test_privkey[32] = { | |||
35 | 0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17 | 36 | 0x36, 0x30, 0xf9, 0x3a, 0x29, 0x52, 0x70, 0x17 |
36 | }; | 37 | }; |
37 | 38 | ||
38 | static char *targetPrivateKeyMultibase = "zrv3kJcnBP1RpYmvNZ9jcYpKBZg41iSobWxSg3ix2U7Cp59kjwQFCT4SZTgLSL3HP8iGMdJs3nedjqYgNn6ZJmsmjRm"; | 39 | static char *targetPublicKeyMultibase = "u7QEJX5oaWV3edV2CeGhkrQPfpaT71ogyVmNk4rZeE8yeRA"; |
39 | |||
40 | static char *targetPublicKeyMultibase = "z6Mkf5rGMoatrSj1f4CyvuHBeXJELe9RPdzo2PKGNCKVtZxP"; | ||
41 | 40 | ||
42 | int | 41 | int |
43 | main () | 42 | main () |
44 | { | 43 | { |
45 | struct GNUNET_CRYPTO_EddsaPrivateKey privkey; | 44 | struct GNUNET_CRYPTO_EddsaPrivateKey privkey; |
46 | struct GNUNET_CRYPTO_EddsaPublicKey pubkey; | 45 | struct GNUNET_CRYPTO_EddsaPublicKey pubkey; |
47 | char *privateKeyMultibase; | ||
48 | char *publicKeyMultibase; | ||
49 | 46 | ||
50 | memcpy (&privkey, test_privkey, sizeof (privkey)); | 47 | memcpy (&privkey, test_privkey, sizeof (privkey)); |
51 | GNUNET_CRYPTO_eddsa_key_get_public (&privkey, &pubkey); | 48 | GNUNET_CRYPTO_eddsa_key_get_public (&privkey, &pubkey); |
52 | 49 | ||
50 | //This is how to convert out pubkeys to W3c Ed25519-2020 multibase (base64url no padding) | ||
51 | char *b64; | ||
52 | char pkx[34]; | ||
53 | pkx[0] = 0xed; | ||
54 | pkx[1] = 0x01; | ||
55 | memcpy (pkx+2, &pubkey, sizeof (pubkey)); | ||
56 | GNUNET_STRINGS_base64url_encode (pkx, | ||
57 | sizeof (pkx), | ||
58 | &b64); | ||
59 | printf ("u%s\n%s\n", b64, targetPublicKeyMultibase); | ||
53 | // FIXME convert pubkey to target | 60 | // FIXME convert pubkey to target |
54 | publicKeyMultibase = "FIXME"; | 61 | char *res; |
55 | GNUNET_assert (0 == strcmp (targetPublicKeyMultibase, | 62 | GNUNET_asprintf (&res, "u%s", b64); |
56 | publicKeyMultibase)); | 63 | GNUNET_assert (0 == strcmp (res, |
57 | 64 | targetPublicKeyMultibase)); | |
58 | // FIXME | ||
59 | privateKeyMultibase = "FIXME"; | ||
60 | GNUNET_assert (0 == strcmp (targetPrivateKeyMultibase, | ||
61 | privateKeyMultibase)); | ||
62 | 65 | ||
66 | GNUNET_free (b64); | ||
67 | GNUNET_free (res); | ||
63 | return 0; | 68 | return 0; |
64 | } | 69 | } |