diff options
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index d5bd53e56..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 | struct GNUNET_IDENTITY_Signature *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,15 +420,25 @@ 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 | |
430 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); | 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); | ||
436 | sig = ((unsigned char*) &pow[1] + ksize); | ||
431 | if (GNUNET_OK != | 437 | if (GNUNET_OK != |
432 | GNUNET_IDENTITY_signature_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 438 | GNUNET_IDENTITY_signature_verify_raw_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
433 | &spurp->purpose, | 439 | &spurp->purpose, |
434 | sig, | 440 | sig, |
435 | key)) | 441 | key)) |
436 | { | 442 | { |
437 | return GNUNET_SYSERR; | 443 | return GNUNET_SYSERR; |
438 | } | 444 | } |
@@ -577,20 +583,11 @@ 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_ (key, | 588 | int result = GNUNET_IDENTITY_sign_raw_ (key, |
592 | &rp->purpose, | 589 | &rp->purpose, |
593 | (void*) sig); | 590 | (void*) sig); |
594 | if (result == GNUNET_SYSERR) | 591 | if (result == GNUNET_SYSERR) |
595 | return GNUNET_NO; | 592 | return GNUNET_NO; |
596 | else | 593 | else |
@@ -768,7 +765,7 @@ GNUNET_REVOCATION_proof_get_size (const struct GNUNET_REVOCATION_PowP *pow) | |||
768 | ksize = GNUNET_IDENTITY_key_get_length (pk); | 765 | ksize = GNUNET_IDENTITY_key_get_length (pk); |
769 | size += ksize; | 766 | size += ksize; |
770 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); | 767 | sig = (struct GNUNET_IDENTITY_Signature *) ((char*) &pow[1] + ksize); |
771 | size += GNUNET_IDENTITY_signature_get_length (sig); | 768 | size += GNUNET_IDENTITY_signature_get_raw_length_by_type (pk->type); |
772 | return size; | 769 | return size; |
773 | } | 770 | } |
774 | 771 | ||