You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
8.0 KiB

  1. /**
  2. * @file key_reset_internal.h
  3. * @brief Functions for resetting partner key defaults and trust and mistrusting and revoking own keys,
  4. * as well as functions to inform partners of own revoked keys and their replacements
  5. * @license GNU General Public License 3.0 - see LICENSE.txt
  6. */
  7. #ifndef KEY_RESET_INTERNAL_H
  8. #define KEY_RESET_INTERNAL_H
  9. #include "pEpEngine.h"
  10. #include "keymanagement.h"
  11. #include "message.h"
  12. #include "message_api.h"
  13. #include "cryptotech.h"
  14. #include "keyreset_command.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * <!-- key_reset() -->
  20. *
  21. * @brief Reset the database status for a key, removing all trust information
  22. * and default database connections. For own keys, also revoke the key
  23. * and communicate the revocation and new key to partners we have sent
  24. * mail to recently from the specific identity (i.e. address/user_id)
  25. * that contacted them. We also in this case set up information so that
  26. * if someone we mail uses the wrong key and wasn't yet contacted,
  27. * we can send them the reset information from the right address.
  28. * For non-own keys, also remove key from the keyring.
  29. *
  30. * Can be called manually or through another protocol.
  31. *
  32. * @param[in] session session handle
  33. * @param[in] fpr fingerprint of key to reset. If NULL and ident is NULL,
  34. * we reset all keys for the own user. If NULL and ident is
  35. * an own identity, we reset the default key for that
  36. * identity. If that own identity has no default key, we
  37. * reset the user default.
  38. * if it is NULL and there is a non-own identity, we will reset
  39. * the default key for this identity if present, and user if not.
  40. * @param[in] ident identity for which the key reset should occur.
  41. * if NULL and fpr is non-NULL, we'll reset the key for all
  42. * associated identities. If both ident and fpr are NULL, see
  43. * the fpr arg documentation.
  44. * ***IF there is an ident, it must have a user_id.***
  45. * Note: ident->fpr is always ignored
  46. * Caveat: this is now used in large part for internal calls.
  47. * external apps should call key_reset_identity and key_reset_userdata
  48. * and this function should probably be removed from the dynamic api
  49. *
  50. *
  51. * @retval PEP_STATUS_OK
  52. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  53. * @retval PEP_OUT_OF_MEMORY out of memory
  54. * @retval any other value on error
  55. */
  56. PEP_STATUS key_reset(
  57. PEP_SESSION session,
  58. const char* fpr,
  59. pEp_identity* ident
  60. );
  61. /*
  62. PEP_STATUS key_reset_own_and_deliver_revocations(PEP_SESSION session,
  63. identity_list** own_identities,
  64. stringlist_t** revocations,
  65. stringlist_t** keys);
  66. */
  67. /**
  68. * <!-- has_key_reset_been_sent() -->
  69. *
  70. * @brief TODO
  71. *
  72. * @param[in] session session handle
  73. * @param[in] from_addr const char*
  74. * @param[in] user_id const char*
  75. * @param[in] revoked_fpr const char*
  76. * @param[in] contacted bool*
  77. *
  78. * @retval PEP_STATUS_OK
  79. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  80. * @retval any other value on error
  81. */
  82. PEP_STATUS has_key_reset_been_sent(
  83. PEP_SESSION session,
  84. const char* from_addr,
  85. const char* user_id,
  86. const char* revoked_fpr,
  87. bool* contacted);
  88. /**
  89. * <!-- set_reset_contact_notified() -->
  90. *
  91. * @brief TODO
  92. *
  93. * @param[in] session session handle
  94. * @param[in] own_address const char*
  95. * @param[in] revoke_fpr const char*
  96. * @param[in] contact_id const char*
  97. *
  98. * @retval PEP_STATUS_OK
  99. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  100. * @retval PEP_UNKNOWN_DB_ERROR
  101. */
  102. PEP_STATUS set_reset_contact_notified(
  103. PEP_SESSION session,
  104. const char* own_address,
  105. const char* revoke_fpr,
  106. const char* contact_id
  107. );
  108. /**
  109. * <!-- receive_key_reset() -->
  110. *
  111. * @brief TODO
  112. *
  113. * @param[in] session session handle
  114. * @param[in] reset_msg message*
  115. *
  116. *
  117. * @retval PEP_STATUS_OK
  118. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  119. * @retval PEP_OUT_OF_MEMORY out of memory
  120. * @retval PEP_MALFORMED_KEY_RESET_MSG
  121. * @retval PEP_KEY_NOT_RESET
  122. * @retval PEP_UNKNOWN_ERROR
  123. * @retval any other value on error
  124. * */
  125. PEP_STATUS receive_key_reset(PEP_SESSION session,
  126. message* reset_msg);
  127. /**
  128. * <!-- create_standalone_key_reset_message() -->
  129. *
  130. * @brief TODO
  131. *
  132. * @param[in] session session handle
  133. * @param[in] dst message**
  134. * @param[in] own_identity pEp_identity*
  135. * @param[in] recip pEp_identity*
  136. * @param[in] old_fpr const char*
  137. * @param[in] new_fpr const char*
  138. *
  139. * @retval PEP_STATUS_OK
  140. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  141. * @retval PEP_UNKNOWN_ERROR
  142. * @retval any other value on error
  143. */
  144. PEP_STATUS create_standalone_key_reset_message(PEP_SESSION session,
  145. message** dst,
  146. pEp_identity* own_identity,
  147. pEp_identity* recip,
  148. const char* old_fpr,
  149. const char* new_fpr);
  150. /**
  151. * <!-- send_key_reset_to_recents() -->
  152. *
  153. * @brief TODO
  154. *
  155. * @param[in] session session handle
  156. * @param[in] from_ident pEp_identity*
  157. * @param[in] old_fpr const char*
  158. * @param[in] new_fpr const char*
  159. *
  160. * @retval PEP_STATUS_OK
  161. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  162. * @retval PEP_SYNC_NO_MESSAGE_SEND_CALLBACK
  163. * @retval any other value on error
  164. */
  165. PEP_STATUS send_key_reset_to_recents(PEP_SESSION session,
  166. pEp_identity* from_ident,
  167. const char* old_fpr,
  168. const char* new_fpr);
  169. /**
  170. * <!-- key_reset_commands_to_PER() -->
  171. *
  172. * @brief TODO
  173. *
  174. * @param[in] command_list const keyreset_command_list*
  175. * @param[in] cmds char**
  176. * @param[in] size size_t*
  177. *
  178. * @retval PEP_STATUS_OK
  179. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  180. * @retval any other value on error
  181. */
  182. PEP_STATUS key_reset_commands_to_PER(const keyreset_command_list *command_list, char **cmds, size_t *size);
  183. /**
  184. * <!-- PER_to_key_reset_commands() -->
  185. *
  186. * @brief TODO
  187. *
  188. * @param[in] cmds const char*
  189. * @param[in] size size_t
  190. * @param[in] command_list keyreset_command_list**
  191. *
  192. * @retval PEP_STATUS_OK
  193. * @retval PEP_ILLEGAL_VALUE illegal parameter values
  194. * @retval any other value on error
  195. */
  196. PEP_STATUS PER_to_key_reset_commands(const char *cmds, size_t size, keyreset_command_list **command_list);
  197. PEP_STATUS key_reset_managed_group(PEP_SESSION session,
  198. pEp_identity* group_identity,
  199. pEp_identity* manager);
  200. PEP_STATUS generate_own_commandlist_msg(PEP_SESSION session,
  201. identity_list* reset_idents,
  202. bool ignore_ungrouped,
  203. pEp_identity* alt_sender,
  204. pEp_identity* alt_recip,
  205. const char* old_fpr,
  206. message** dst);
  207. #ifdef __cplusplus
  208. }
  209. #endif
  210. #endif