gnunet_revocation_service.h 4.6 KB

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