diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 21:10:09 +0100 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-02-01 21:10:09 +0100 |
commit | ad6bc2037ffee49f6df1a3ac87fa507581af2365 (patch) | |
tree | b9fe5afc2bc1c0887bfd0b194c19c71ace21a21b /src/revocation | |
parent | 4f07822ff0f5c13ff6052f531da249363d5116f8 (diff) | |
download | gnunet-ad6bc2037ffee49f6df1a3ac87fa507581af2365.tar.gz gnunet-ad6bc2037ffee49f6df1a3ac87fa507581af2365.zip |
- add plaintext message to revocation tvg
Diffstat (limited to 'src/revocation')
-rw-r--r-- | src/revocation/gnunet-revocation-tvg.c | 10 | ||||
-rw-r--r-- | src/revocation/revocation.h | 8 | ||||
-rw-r--r-- | 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 @@ | |||
29 | #include "gnunet_revocation_service.h" | 29 | #include "gnunet_revocation_service.h" |
30 | #include "gnunet_dnsparser_lib.h" | 30 | #include "gnunet_dnsparser_lib.h" |
31 | #include "gnunet_testing_lib.h" | 31 | #include "gnunet_testing_lib.h" |
32 | #include "revocation.h" | ||
32 | #include <inttypes.h> | 33 | #include <inttypes.h> |
33 | 34 | ||
34 | #define TEST_EPOCHS 2 | 35 | #define TEST_EPOCHS 2 |
@@ -140,6 +141,15 @@ run (void *cls, | |||
140 | { | 141 | { |
141 | pow_passes++; | 142 | pow_passes++; |
142 | } | 143 | } |
144 | struct GNUNET_REVOCATION_SignaturePurposePS *purp; | ||
145 | purp = REV_create_signature_message (pow); | ||
146 | fprintf (stdout, "Signed message:\n"); | ||
147 | print_bytes (purp, | ||
148 | ntohl (purp->purpose.size), | ||
149 | 8); | ||
150 | printf ("\n"); | ||
151 | GNUNET_free (purp); | ||
152 | |||
143 | exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, | 153 | exp = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_YEARS, |
144 | TEST_EPOCHS); | 154 | TEST_EPOCHS); |
145 | GNUNET_assert (GNUNET_OK == GNUNET_REVOCATION_check_pow (pow, | 155 | 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 | |||
113 | 113 | ||
114 | GNUNET_NETWORK_STRUCT_END | 114 | GNUNET_NETWORK_STRUCT_END |
115 | 115 | ||
116 | /** | ||
117 | * Create the revocation metadata to sign for a revocation message | ||
118 | * | ||
119 | * @param pow the PoW to sign | ||
120 | * @return the signature purpose | ||
121 | */ | ||
122 | struct GNUNET_REVOCATION_SignaturePurposePS * | ||
123 | REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow); | ||
116 | 124 | ||
117 | #endif | 125 | #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) | |||
404 | return avg; | 404 | return avg; |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | struct GNUNET_REVOCATION_SignaturePurposePS * | |
408 | enum GNUNET_GenericReturnValue | 408 | REV_create_signature_message (const struct GNUNET_REVOCATION_PowP *pow) |
409 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | ||
410 | const struct GNUNET_IDENTITY_PublicKey *key) | ||
411 | { | 409 | { |
412 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; | 410 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; |
413 | unsigned char *sig; | ||
414 | const struct GNUNET_IDENTITY_PublicKey *pk; | 411 | const struct GNUNET_IDENTITY_PublicKey *pk; |
415 | size_t ksize; | 412 | size_t ksize; |
416 | 413 | ||
417 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 414 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
418 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 415 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
419 | |||
420 | spurp = GNUNET_malloc (sizeof (*spurp) + ksize); | 416 | spurp = GNUNET_malloc (sizeof (*spurp) + ksize); |
421 | spurp->timestamp = pow->timestamp; | 417 | spurp->timestamp = pow->timestamp; |
422 | spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 418 | spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); |
@@ -424,9 +420,19 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | |||
424 | GNUNET_IDENTITY_write_key_to_buffer (pk, | 420 | GNUNET_IDENTITY_write_key_to_buffer (pk, |
425 | (char*) &spurp[1], | 421 | (char*) &spurp[1], |
426 | ksize); | 422 | ksize); |
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 423 | return spurp; |
428 | "Expected signature payload len: %u\n", | 424 | } |
429 | ntohl (spurp->purpose.size)); | 425 | |
426 | enum GNUNET_GenericReturnValue | ||
427 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | ||
428 | const struct GNUNET_IDENTITY_PublicKey *key) | ||
429 | { | ||
430 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; | ||
431 | unsigned char *sig; | ||
432 | size_t ksize; | ||
433 | |||
434 | ksize = GNUNET_IDENTITY_key_get_length (key); | ||
435 | spurp = REV_create_signature_message (pow); | ||
430 | sig = ((unsigned char*) &pow[1] + ksize); | 436 | sig = ((unsigned char*) &pow[1] + ksize); |
431 | if (GNUNET_OK != | 437 | if (GNUNET_OK != |
432 | GNUNET_IDENTITY_signature_verify_raw_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 438 | GNUNET_IDENTITY_signature_verify_raw_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
@@ -577,16 +583,7 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
577 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 583 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
578 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 584 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
579 | pow->timestamp = GNUNET_TIME_absolute_hton (ts); | 585 | pow->timestamp = GNUNET_TIME_absolute_hton (ts); |
580 | rp = GNUNET_malloc (sizeof (*rp) + ksize); | 586 | rp = REV_create_signature_message (pow); |
581 | rp->timestamp = pow->timestamp; | ||
582 | rp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | ||
583 | rp->purpose.size = htonl (sizeof(*rp) + ksize); | ||
584 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
585 | "Signature payload len: %u\n", | ||
586 | ntohl (rp->purpose.size)); | ||
587 | GNUNET_IDENTITY_write_key_to_buffer (pk, | ||
588 | ((char*) &rp[1]), | ||
589 | ksize); | ||
590 | sig = ((char*) &pow[1]) + ksize; | 587 | sig = ((char*) &pow[1]) + ksize; |
591 | int result = GNUNET_IDENTITY_sign_raw_ (key, | 588 | int result = GNUNET_IDENTITY_sign_raw_ (key, |
592 | &rp->purpose, | 589 | &rp->purpose, |