diff options
Diffstat (limited to 'src/include/gnunet_identity_service.h')
-rw-r--r-- | src/include/gnunet_identity_service.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/include/gnunet_identity_service.h b/src/include/gnunet_identity_service.h index b2a45577f..227c7f486 100644 --- a/src/include/gnunet_identity_service.h +++ b/src/include/gnunet_identity_service.h | |||
@@ -459,6 +459,21 @@ GNUNET_IDENTITY_signature_get_length (const struct | |||
459 | 459 | ||
460 | 460 | ||
461 | /** | 461 | /** |
462 | * Get the compacted length of a signature by type. | ||
463 | * Compacted means that it returns the minimum number of bytes this | ||
464 | * signature is long, as opposed to the union structure inside | ||
465 | * #GNUNET_IDENTITY_Signature. | ||
466 | * Useful for compact serializations. | ||
467 | * | ||
468 | * @param sig the signature. | ||
469 | * @return -1 on error, else the compacted length of the signature. | ||
470 | */ | ||
471 | ssize_t | ||
472 | GNUNET_IDENTITY_signature_get_raw_length_by_type (const uint32_t type); | ||
473 | |||
474 | |||
475 | |||
476 | /** | ||
462 | * Reads a #GNUNET_IDENTITY_Signature from a compact buffer. | 477 | * Reads a #GNUNET_IDENTITY_Signature from a compact buffer. |
463 | * The buffer has to contain at least the compacted length of | 478 | * The buffer has to contain at least the compacted length of |
464 | * a #GNUNET_IDENTITY_Signature in bytes. | 479 | * a #GNUNET_IDENTITY_Signature in bytes. |
@@ -516,6 +531,26 @@ GNUNET_IDENTITY_sign_ (const struct | |||
516 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | 531 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, |
517 | struct GNUNET_IDENTITY_Signature *sig); | 532 | struct GNUNET_IDENTITY_Signature *sig); |
518 | 533 | ||
534 | /** | ||
535 | * @brief Sign a given block. | ||
536 | * | ||
537 | * The @a purpose data is the beginning of the data of which the signature is | ||
538 | * to be created. The `size` field in @a purpose must correctly indicate the | ||
539 | * number of bytes of the data structure, including its header. | ||
540 | * The signature payload and length depends on the key type. | ||
541 | * | ||
542 | * @param priv private key to use for the signing | ||
543 | * @param purpose what to sign (size, purpose) | ||
544 | * @param[out] sig where to write the signature | ||
545 | * @return #GNUNET_SYSERR on error, #GNUNET_OK on success | ||
546 | */ | ||
547 | enum GNUNET_GenericReturnValue | ||
548 | GNUNET_IDENTITY_sign_raw_ (const struct | ||
549 | GNUNET_IDENTITY_PrivateKey *priv, | ||
550 | const struct | ||
551 | GNUNET_CRYPTO_EccSignaturePurpose *purpose, | ||
552 | unsigned char *sig); | ||
553 | |||
519 | 554 | ||
520 | /** | 555 | /** |
521 | * @brief Sign a given block with #GNUNET_IDENTITY_PrivateKey. | 556 | * @brief Sign a given block with #GNUNET_IDENTITY_PrivateKey. |
@@ -566,6 +601,30 @@ GNUNET_IDENTITY_signature_verify_ (uint32_t purpose, | |||
566 | const struct | 601 | const struct |
567 | GNUNET_IDENTITY_PublicKey *pub); | 602 | GNUNET_IDENTITY_PublicKey *pub); |
568 | 603 | ||
604 | /** | ||
605 | * @brief Verify a given signature. | ||
606 | * | ||
607 | * The @a validate data is the beginning of the data of which the signature | ||
608 | * is to be verified. The `size` field in @a validate must correctly indicate | ||
609 | * the number of bytes of the data structure, including its header. If @a | ||
610 | * purpose does not match the purpose given in @a validate (the latter must be | ||
611 | * in big endian), signature verification fails. | ||
612 | * | ||
613 | * @param purpose what is the purpose that the signature should have? | ||
614 | * @param validate block to validate (size, purpose, data) | ||
615 | * @param sig signature that is being validated | ||
616 | * @param pub public key of the signer | ||
617 | * @returns #GNUNET_OK if ok, #GNUNET_SYSERR if invalid | ||
618 | */ | ||
619 | enum GNUNET_GenericReturnValue | ||
620 | GNUNET_IDENTITY_signature_verify_raw_ (uint32_t purpose, | ||
621 | const struct | ||
622 | GNUNET_CRYPTO_EccSignaturePurpose * | ||
623 | validate, | ||
624 | const unsigned char *sig, | ||
625 | const struct | ||
626 | GNUNET_IDENTITY_PublicKey *pub); | ||
627 | |||
569 | 628 | ||
570 | /** | 629 | /** |
571 | * @brief Verify a given signature with #GNUNET_IDENTITY_PublicKey. | 630 | * @brief Verify a given signature with #GNUNET_IDENTITY_PublicKey. |