diff options
Diffstat (limited to 'src/revocation/revocation_api.c')
-rw-r--r-- | src/revocation/revocation_api.c | 53 |
1 files changed, 19 insertions, 34 deletions
diff --git a/src/revocation/revocation_api.c b/src/revocation/revocation_api.c index 94fbc7022..ee0150064 100644 --- a/src/revocation/revocation_api.c +++ b/src/revocation/revocation_api.c | |||
@@ -423,19 +423,18 @@ calculate_score (const struct GNUNET_REVOCATION_PowCalculationHandle *ph) | |||
423 | 423 | ||
424 | 424 | ||
425 | enum GNUNET_GenericReturnValue | 425 | enum GNUNET_GenericReturnValue |
426 | check_signature_ecdsa (const struct GNUNET_REVOCATION_PowP *pow, | 426 | check_signature_identity (const struct GNUNET_REVOCATION_PowP *pow, |
427 | const struct GNUNET_CRYPTO_EcdsaPublicKey *key) | 427 | const struct GNUNET_IDENTITY_PublicKey *key) |
428 | { | 428 | { |
429 | struct GNUNET_REVOCATION_EcdsaSignaturePurposePS spurp; | 429 | struct GNUNET_REVOCATION_SignaturePurposePS spurp; |
430 | struct GNUNET_CRYPTO_EcdsaSignature *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; |
433 | 433 | ||
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.ktype = pk->type; | 437 | spurp.key = *pk; |
438 | spurp.key = pk->ecdsa_key; | ||
439 | spurp.timestamp = pow->timestamp; | 438 | spurp.timestamp = pow->timestamp; |
440 | spurp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); | 439 | spurp.purpose.purpose = htonl (GNUNET_SIGNATURE_PURPOSE_REVOCATION); |
441 | spurp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) | 440 | spurp.purpose.size = htonl (sizeof(struct GNUNET_CRYPTO_EccSignaturePurpose) |
@@ -446,10 +445,10 @@ check_signature_ecdsa (const struct GNUNET_REVOCATION_PowP *pow, | |||
446 | ntohl (spurp.purpose.size)); | 445 | ntohl (spurp.purpose.size)); |
447 | sig = (struct GNUNET_CRYPTO_EcdsaSignature *) ((char*)&pow[1] + ksize); | 446 | sig = (struct GNUNET_CRYPTO_EcdsaSignature *) ((char*)&pow[1] + ksize); |
448 | if (GNUNET_OK != | 447 | if (GNUNET_OK != |
449 | GNUNET_CRYPTO_ecdsa_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, | 448 | GNUNET_IDENTITY_public_key_verify_ (GNUNET_SIGNATURE_PURPOSE_REVOCATION, |
450 | &spurp.purpose, | 449 | &spurp.purpose, |
451 | sig, | 450 | sig, |
452 | key)) | 451 | key)) |
453 | { | 452 | { |
454 | return GNUNET_SYSERR; | 453 | return GNUNET_SYSERR; |
455 | } | 454 | } |
@@ -463,14 +462,7 @@ check_signature (const struct GNUNET_REVOCATION_PowP *pow) | |||
463 | const struct GNUNET_IDENTITY_PublicKey *pk; | 462 | const struct GNUNET_IDENTITY_PublicKey *pk; |
464 | 463 | ||
465 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 464 | pk = (const struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
466 | switch (ntohl (pk->type)) | 465 | return check_signature_identity (pow, pk); |
467 | { | ||
468 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
469 | return check_signature_ecdsa (pow, &pk->ecdsa_key); | ||
470 | default: | ||
471 | return GNUNET_SYSERR; | ||
472 | } | ||
473 | return GNUNET_SYSERR; | ||
474 | } | 466 | } |
475 | 467 | ||
476 | 468 | ||
@@ -576,11 +568,11 @@ GNUNET_REVOCATION_check_pow (const struct GNUNET_REVOCATION_PowP *pow, | |||
576 | 568 | ||
577 | 569 | ||
578 | enum GNUNET_GenericReturnValue | 570 | enum GNUNET_GenericReturnValue |
579 | sign_pow_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | 571 | sign_pow_identity (const struct GNUNET_IDENTITY_PrivateKey *key, |
580 | struct GNUNET_REVOCATION_PowP *pow) | 572 | struct GNUNET_REVOCATION_PowP *pow) |
581 | { | 573 | { |
582 | struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); | 574 | struct GNUNET_TIME_Absolute ts = GNUNET_TIME_absolute_get (); |
583 | struct GNUNET_REVOCATION_EcdsaSignaturePurposePS rp; | 575 | struct GNUNET_REVOCATION_SignaturePurposePS rp; |
584 | const struct GNUNET_IDENTITY_PublicKey *pk; | 576 | const struct GNUNET_IDENTITY_PublicKey *pk; |
585 | size_t ksize; | 577 | size_t ksize; |
586 | char *sig; | 578 | char *sig; |
@@ -602,13 +594,13 @@ sign_pow_ecdsa (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key, | |||
602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 594 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
603 | "Signature payload len: %u\n", | 595 | "Signature payload len: %u\n", |
604 | ntohl (rp.purpose.size)); | 596 | ntohl (rp.purpose.size)); |
605 | rp.ktype = pk->type; | 597 | rp.key = *pk; |
606 | rp.key = pk->ecdsa_key; | ||
607 | sig = ((char*)&pow[1]) + ksize; | 598 | sig = ((char*)&pow[1]) + ksize; |
608 | return GNUNET_CRYPTO_ecdsa_sign_ (key, | 599 | int result = GNUNET_IDENTITY_private_key_sign_ (key, |
609 | &rp.purpose, | 600 | &rp.purpose, |
610 | (void*) sig); | 601 | (void*) sig); |
611 | 602 | if (result == GNUNET_SYSERR) return GNUNET_NO; | |
603 | else return result; | ||
612 | } | 604 | } |
613 | 605 | ||
614 | 606 | ||
@@ -620,14 +612,7 @@ sign_pow (const struct GNUNET_IDENTITY_PrivateKey *key, | |||
620 | 612 | ||
621 | pk = (struct GNUNET_IDENTITY_PublicKey *) &pow[1]; | 613 | pk = (struct GNUNET_IDENTITY_PublicKey *) &pow[1]; |
622 | GNUNET_IDENTITY_key_get_public (key, pk); | 614 | GNUNET_IDENTITY_key_get_public (key, pk); |
623 | switch (ntohl (pk->type)) | 615 | return sign_pow_identity (key, pow); |
624 | { | ||
625 | case GNUNET_IDENTITY_TYPE_ECDSA: | ||
626 | return sign_pow_ecdsa (&key->ecdsa_key, pow); | ||
627 | default: | ||
628 | return GNUNET_NO; | ||
629 | } | ||
630 | return GNUNET_NO; | ||
631 | } | 616 | } |
632 | 617 | ||
633 | 618 | ||