diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 15:48:52 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 15:48:52 +0100 |
commit | 816bab695d6a7f4e359865e83b687d45ff66a2b1 (patch) | |
tree | 9e36e1d3d61e402a00119b727855fd71f01b795c /src/revocation | |
parent | 8e8f974d798b20e298de6583e8ad0b07ef9b0992 (diff) | |
download | gnunet-816bab695d6a7f4e359865e83b687d45ff66a2b1.tar.gz gnunet-816bab695d6a7f4e359865e83b687d45ff66a2b1.zip |
GNS: Fix revocation wire format
Diffstat (limited to 'src/revocation')
-rw-r--r-- | src/revocation/gnunet-revocation-tvg.c | 23 | ||||
-rw-r--r-- | src/revocation/revocation_api.c | 20 |
2 files changed, 33 insertions, 10 deletions
diff --git a/src/revocation/gnunet-revocation-tvg.c b/src/revocation/gnunet-revocation-tvg.c index 0838cecc4..f1d4b0334 100644 --- a/src/revocation/gnunet-revocation-tvg.c +++ b/src/revocation/gnunet-revocation-tvg.c | |||
@@ -34,6 +34,28 @@ | |||
34 | #define TEST_EPOCHS 2 | 34 | #define TEST_EPOCHS 2 |
35 | #define TEST_DIFFICULTY 5 | 35 | #define TEST_DIFFICULTY 5 |
36 | 36 | ||
37 | static char* d_pkey = | ||
38 | "6fea32c05af58bfa979553d188605fd57d8bf9cc263b78d5f7478c07b998ed70"; | ||
39 | |||
40 | int parsehex(char *src, char *dst, size_t dstlen, int invert) | ||
41 | { | ||
42 | char *line = src; | ||
43 | char *data = line; | ||
44 | int off; | ||
45 | int read_byte; | ||
46 | int data_len = 0; | ||
47 | |||
48 | while (sscanf(data, " %02x%n", &read_byte, &off) == 1) { | ||
49 | if (invert) | ||
50 | dst[dstlen - 1 - data_len++] = read_byte; | ||
51 | else | ||
52 | dst[data_len++] = read_byte; | ||
53 | data += off; | ||
54 | } | ||
55 | return data_len; | ||
56 | } | ||
57 | |||
58 | |||
37 | static void | 59 | static void |
38 | print_bytes_ (void *buf, | 60 | print_bytes_ (void *buf, |
39 | size_t buf_len, | 61 | size_t buf_len, |
@@ -87,6 +109,7 @@ run (void *cls, | |||
87 | 109 | ||
88 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); | 110 | id_priv.type = htonl (GNUNET_IDENTITY_TYPE_ECDSA); |
89 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); | 111 | GNUNET_CRYPTO_ecdsa_key_create (&id_priv.ecdsa_key); |
112 | parsehex(d_pkey,(char*)&id_priv.ecdsa_key, sizeof (id_priv.ecdsa_key), 1); | ||
90 | GNUNET_IDENTITY_key_get_public (&id_priv, | 113 | GNUNET_IDENTITY_key_get_public (&id_priv, |
91 | &id_pub); | 114 | &id_pub); |
92 | GNUNET_STRINGS_data_to_string (&id_pub, | 115 | GNUNET_STRINGS_data_to_string (&id_pub, |
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index d5bd53e56..8f05b88fd 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -410,7 +410,7 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | |||
410 | const struct GNUNET_IDENTITY_PublicKey *key) | 410 | const struct GNUNET_IDENTITY_PublicKey *key) |
411 | { | 411 | { |
412 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; | 412 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; |
413 | struct GNUNET_IDENTITY_Signature *sig; | 413 | unsigned char *sig; |
414 | const struct GNUNET_IDENTITY_PublicKey *pk; | 414 | const struct GNUNET_IDENTITY_PublicKey *pk; |
415 | size_t ksize; | 415 | size_t ksize; |
416 | 416 | ||
@@ -427,12 +427,12 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | |||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
428 | "Expected signature payload len: %u\n", | 428 | "Expected signature payload len: %u\n", |
429 | ntohl (spurp->purpose.size)); | 429 | ntohl (spurp->purpose.size)); |
430 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); | 430 | sig = ((unsigned char*) &pow[1] + ksize); |
431 | if (GNUNET_OK != | 431 | if (GNUNET_OK != |
432 | GNUNET_IDENTITY_signature_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 432 | GNUNET_IDENTITY_signature_verify_raw_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
433 | &spurp->purpose, | 433 | &spurp->purpose, |
434 | sig, | 434 | sig, |
435 | key)) | 435 | key)) |
436 | { | 436 | { |
437 | return GNUNET_SYSERR; | 437 | return GNUNET_SYSERR; |
438 | } | 438 | } |
@@ -588,9 +588,9 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
588 | ((char*) &rp[1]), | 588 | ((char*) &rp[1]), |
589 | ksize); | 589 | ksize); |
590 | sig = ((char*) &pow[1]) + ksize; | 590 | sig = ((char*) &pow[1]) + ksize; |
591 | int result = GNUNET_IDENTITY_sign_ (key, | 591 | int result = GNUNET_IDENTITY_sign_raw_ (key, |
592 | &rp->purpose, | 592 | &rp->purpose, |
593 | (void*) sig); | 593 | (void*) sig); |
594 | if (result == GNUNET_SYSERR) | 594 | if (result == GNUNET_SYSERR) |
595 | return GNUNET_NO; | 595 | return GNUNET_NO; |
596 | else | 596 | else |
@@ -768,7 +768,7 @@ GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) | |||
768 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 768 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
769 | size += ksize; | 769 | size += ksize; |
770 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); | 770 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); |
771 | size += GNUNET_IDENTITY_signature_get_length (sig); | 771 | size += GNUNET_IDENTITY_signature_get_raw_length_by_type (pk->type); |
772 | return size; | 772 | return size; |
773 | } | 773 | } |
774 | 774 | ||