diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2020-11-10 09:01:17 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2020-11-10 09:01:17 +0900 |
commit | 5306c3356854b535fe09654b270f06615bf94e94 (patch) | |
tree | 7fa1c8c677d9d89823b7cd0563f020d9e0d73c61 /src/revocation/revocation_api.c | |
parent | ca808598b9c28e1bb089d2d8cb7ec9332f2c0137 (diff) | |
download | gnunet-5306c3356854b535fe09654b270f06615bf94e94.tar.gz gnunet-5306c3356854b535fe09654b270f06615bf94e94.zip |
-fix signatures in revocation
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index ee0150064..44c42ae49 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -426,7 +426,7 @@ enum GNUNET_GenericReturnValue | |||
426 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | 426 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, |
427 | const struct GNUNET_IDENTITY_PublicKey *key) | 427 | const struct GNUNET_IDENTITY_PublicKey *key) |
428 | { | 428 | { |
429 | struct GNUNET_REVOCATION_SignaturePurposePS spurp; | 429 | struct GNUNET_REVOCATION_SignaturePurposePS *spurp; |
430 | struct GNUNET_IDENTITY_Signature *sig; | 430 | struct GNUNET_IDENTITY_Signature *sig; |
431 | const struct GNUNET_IDENTITY_PublicKey *pk; | 431 | const struct GNUNET_IDENTITY_PublicKey *pk; |
432 | size_t ksize; | 432 | size_t ksize; |
@@ -434,19 +434,20 @@ check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, | |||
434 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 434 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
435 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 435 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
436 | 436 | ||
437 | spurp.key = *pk; | 437 | spurp = GNUNET_malloc (sizeof (*spurp) + ksize); |
438 | spurp.timestamp = pow->timestamp; | 438 | spurp->timestamp = pow->timestamp; |
439 | spurp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 439 | spurp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); |
440 | spurp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 440 | spurp->purpose.size = htonl (sizeof(*spurp) + ksize); |
441 | + GNUNET_IDENTITY_key_get_length (pk) | 441 | GNUNET_IDENTITY_write_key_to_buffer (pk, |
442 | + sizeof (struct GNUNET_TIME_AbsoluteNBO)); | 442 | (char*) &spurp[1], |
443 | ksize); | ||
443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 444 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
444 | "Expected signature payload len: %u\n", | 445 | "Expected signature payload len: %u\n", |
445 | ntohl (spurp.purpose.size)); | 446 | ntohl (spurp->purpose.size)); |
446 | sig = (struct GNUNET_CRYPTO_EcdsaSignature *) ((char*)&pow[1] + ksize); | 447 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); |
447 | if (GNUNET_OK != | 448 | if (GNUNET_OK != |
448 | GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 449 | GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
449 | &spurp.purpose, | 450 | &spurp->purpose, |
450 | sig, | 451 | sig, |
451 | key)) | 452 | key)) |
452 | { | 453 | { |
@@ -572,7 +573,7 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
572 | struct GNUNET_REVOCATION_PowP *pow) | 573 | struct GNUNET_REVOCATION_PowP *pow) |
573 | { | 574 | { |
574 | struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); | 575 | struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); |
575 | struct GNUNET_REVOCATION_SignaturePurposePS rp; | 576 | struct GNUNET_REVOCATION_SignaturePurposePS *rp; |
576 | const struct GNUNET_IDENTITY_PublicKey *pk; | 577 | const struct GNUNET_IDENTITY_PublicKey *pk; |
577 | size_t ksize; | 578 | size_t ksize; |
578 | char *sig; | 579 | char *sig; |
@@ -586,18 +587,19 @@ sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
586 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 587 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
587 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 588 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
588 | pow->timestamp = GNUNET_TIME_absolute_hton (ts); | 589 | pow->timestamp = GNUNET_TIME_absolute_hton (ts); |
589 | rp.timestamp = pow->timestamp; | 590 | rp = GNUNET_malloc (sizeof (*rp) + ksize); |
590 | rp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 591 | rp->timestamp = pow->timestamp; |
591 | rp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 592 | rp->purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); |
592 | + ksize | 593 | rp->purpose.size = htonl (sizeof(*rp) + ksize); |
593 | + sizeof (struct GNUNET_TIME_AbsoluteNBO)); | ||
594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
595 | "Signature payload len: %u\n", | 595 | "Signature payload len: %u\n", |
596 | ntohl (rp.purpose.size)); | 596 | ntohl (rp->purpose.size)); |
597 | rp.key = *pk; | 597 | GNUNET_IDENTITY_write_key_to_buffer (pk, |
598 | ((char*)&rp[1]), | ||
599 | ksize); | ||
598 | sig = ((char*)&pow[1]) + ksize; | 600 | sig = ((char*)&pow[1]) + ksize; |
599 | int result = GNUNET_IDENTITY_private_key_sign_ (key, | 601 | int result = GNUNET_IDENTITY_private_key_sign_ (key, |
600 | &rp.purpose, | 602 | &rp->purpose, |
601 | (void*) sig); | 603 | (void*) sig); |
602 | if (result == GNUNET_SYSERR) return GNUNET_NO; | 604 | if (result == GNUNET_SYSERR) return GNUNET_NO; |
603 | else return result; | 605 | else return result; |
@@ -762,20 +764,17 @@ size_t | |||
762 | GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) | 764 | GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) |
763 | { | 765 | { |
764 | size_t size; | 766 | size_t size; |
767 | size_t ksize; | ||
765 | const struct GNUNET_IDENTITY_PublicKey *pk; | 768 | const struct GNUNET_IDENTITY_PublicKey *pk; |
769 | const struct GNUNET_IDENTITY_Signature *sig; | ||
766 | 770 | ||
767 | size = sizeof (struct GNUNET_REVOCATION_PowP); | 771 | size = sizeof (struct GNUNET_REVOCATION_PowP); |
768 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 772 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
769 | size += GNUNET_IDENTITY_key_get_length (pk); | 773 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
770 | 774 | size += ksize; | |
771 | switch (ntohl (pk->type)) | 775 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*)&pow[1] + ksize); |
772 | { | 776 | size += GNUNET_IDENTITY_signature_get_length (sig); |
773 | case GNUNET_IDENTITY_TYPE_ECDSA: | 777 | return size; |
774 | return size + sizeof (struct GNUNET_CRYPTO_EcdsaSignature); | ||
775 | default: | ||
776 | return 0; | ||
777 | } | ||
778 | return 0; | ||
779 | } | 778 | } |
780 | 779 | ||
781 | 780 | ||