gnunet_revocation_service.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. This file is part of GNUnet
  3. Copyright (C) 2013 GNUnet e.V.
  4. GNUnet is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Affero General Public License as published
  6. by the Free Software Foundation, either version 3 of the License,
  7. or (at your option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. SPDX-License-Identifier: AGPL3.0-or-later
  15. */
  16. #ifndef GNUNET_REVOCATION_SERVICE_H_
  17. #define GNUNET_REVOCATION_SERVICE_H_
  18. /**
  19. * @author Christian Grothoff
  20. *
  21. * @file
  22. * API to perform and access key revocations
  23. *
  24. * @defgroup revocation Revocation service
  25. * Perform and access key revocations.
  26. *
  27. * @see [Documentation](https://gnunet.org/revocation-subsystem)
  28. *
  29. * @{
  30. */
  31. #ifdef __cplusplus
  32. extern "C"
  33. {
  34. #if 0 /* keep Emacsens' auto-indent happy */
  35. }
  36. #endif
  37. #endif
  38. #include "gnunet_util_lib.h"
  39. /**
  40. * Version of the key revocation API.
  41. */
  42. #define GNUNET_REVOCATION_VERSION 0x00000000
  43. /**
  44. * Handle for the key revocation query.
  45. */
  46. struct GNUNET_REVOCATION_Query;
  47. /**
  48. * Callback to call with the result of a key revocation query.
  49. *
  50. * @param cls closure
  51. * @param is_valid #GNUNET_NO of the key is/was revoked,
  52. * #GNUNET_YES if the key is still valid,
  53. * #GNUNET_SYSERR if we had trouble querying the service
  54. *
  55. */
  56. typedef void (*GNUNET_REVOCATION_Callback) (void *cls,
  57. int is_valid);
  58. /**
  59. * Check if a key was revoked.
  60. *
  61. * @param cfg the configuration to use
  62. * @param key key to check for revocation
  63. * @param func funtion to call with the result of the check
  64. * @param func_cls closure to pass to @a func
  65. * @return handle to use in #GNUNET_REVOCATION_query_cancel to stop REVOCATION from invoking the callback
  66. */
  67. struct GNUNET_REVOCATION_Query *
  68. GNUNET_REVOCATION_query (const struct GNUNET_CONFIGURATION_Handle *cfg,
  69. const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
  70. GNUNET_REVOCATION_Callback func, void *func_cls);
  71. /**
  72. * Cancel key revocation check.
  73. *
  74. * @param q query to cancel
  75. */
  76. void
  77. GNUNET_REVOCATION_query_cancel (struct GNUNET_REVOCATION_Query *q);
  78. /**
  79. * Handle for the key revocation operation.
  80. */
  81. struct GNUNET_REVOCATION_Handle;
  82. /**
  83. * Perform key revocation.
  84. *
  85. * @param cfg the configuration to use
  86. * @param key public key of the key to revoke
  87. * @param sig signature to use on the revocation (should have been
  88. * created using #GNUNET_REVOCATION_sign_revocation).
  89. * @param pow proof of work to use (should have been created by
  90. * iteratively calling #GNUNET_REVOCATION_check_pow)
  91. * @param func funtion to call with the result of the check
  92. * (called with `is_valid` being #GNUNET_NO if
  93. * the revocation worked).
  94. * @param func_cls closure to pass to @a func
  95. * @return handle to use in #GNUNET_REVOCATION_revoke_cancel to stop REVOCATION from invoking the callback
  96. */
  97. struct GNUNET_REVOCATION_Handle *
  98. GNUNET_REVOCATION_revoke (const struct GNUNET_CONFIGURATION_Handle *cfg,
  99. const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
  100. const struct GNUNET_CRYPTO_EcdsaSignature *sig,
  101. uint64_t pow,
  102. GNUNET_REVOCATION_Callback func, void *func_cls);
  103. /**
  104. * Cancel key revocation.
  105. *
  106. * @param h operation to cancel
  107. */
  108. void
  109. GNUNET_REVOCATION_revoke_cancel (struct GNUNET_REVOCATION_Handle *h);
  110. /**
  111. * Check if the given proof-of-work value
  112. * would be acceptable for revoking the given key.
  113. *
  114. * @param key key to check for
  115. * @param pow proof of work value
  116. * @param matching_bits how many bits must match (configuration)
  117. * @return #GNUNET_YES if the @a pow is acceptable, #GNUNET_NO if not
  118. */
  119. int
  120. GNUNET_REVOCATION_check_pow (const struct GNUNET_CRYPTO_EcdsaPublicKey *key,
  121. uint64_t pow,
  122. unsigned int matching_bits);
  123. /**
  124. * Create a revocation signature.
  125. *
  126. * @param key private key of the key to revoke
  127. * @param sig where to write the revocation signature
  128. */
  129. void
  130. GNUNET_REVOCATION_sign_revocation (const struct GNUNET_CRYPTO_EcdsaPrivateKey *key,
  131. struct GNUNET_CRYPTO_EcdsaSignature *sig);
  132. #if 0 /* keep Emacsens' auto-indent happy */
  133. {
  134. #endif
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif /* GNUNET_REVOCATION_SERVICE_H_ */
  139. /** @} */ /* end of group revocation */