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.

284 lines
7.5 KiB

6 years ago
8 years ago
7 years ago
6 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
6 years ago
8 years ago
8 years ago
7 years ago
8 years ago
  1. /**
  2. * @file cryptotech.h
  3. * @brief cryptotech function typedefs and structures for crypto drivers
  4. * to implement and interface with engine
  5. * @license GNU General Public License 3.0 - see LICENSE.txt
  6. */
  7. #ifndef CRYPTOTECH_H
  8. #define CRYPTOTECH_H
  9. #include "pEpEngine.h"
  10. #include "bloblist.h"
  11. /**
  12. * @enum PEP_cryptotech
  13. *
  14. * @brief TODO
  15. *
  16. */
  17. typedef enum _PEP_cryptotech {
  18. PEP_crypt_none = 0,
  19. PEP_crypt_OpenPGP,
  20. // PEP_ctypt_PEP,
  21. // PEP_crypt_SMIME,
  22. // PEP_crypt_CMS,
  23. PEP_crypt__count
  24. } PEP_cryptotech;
  25. /**
  26. * @copydoc decrypt_and_verify()
  27. * Signature for crypto drivers to implement for decrypt_and_verify()
  28. * @see decrypt_and_verify()
  29. */
  30. typedef PEP_STATUS (*decrypt_and_verify_t)(
  31. PEP_SESSION session, const char *ctext, size_t csize,
  32. const char *dsigtext, size_t dsigsize,
  33. char **ptext, size_t *psize, stringlist_t **keylist,
  34. char **filename_ptr
  35. );
  36. /**
  37. * @copydoc verify_text()
  38. * Signature for crypto drivers to implement for verify_text()
  39. * @see verify_text()
  40. */
  41. typedef PEP_STATUS (*verify_text_t)(
  42. PEP_SESSION session, const char *text, size_t size,
  43. const char *signature, size_t sig_size, stringlist_t **keylist
  44. );
  45. /**
  46. * @copydoc encrypt_and_sign()
  47. * Signature for crypto drivers to implement for encrypt_and_sign()
  48. * @see encrypt_and_sign()
  49. */
  50. typedef PEP_STATUS (*encrypt_and_sign_t)(
  51. PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
  52. size_t psize, char **ctext, size_t *csize
  53. );
  54. /**
  55. * @copydoc encrypt_only()
  56. * Signature for crypto drivers to implement for encrypt_only()
  57. * @see encrypt_only()
  58. */
  59. typedef PEP_STATUS (*encrypt_only_t)(
  60. PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
  61. size_t psize, char **ctext, size_t *csize
  62. );
  63. /**
  64. * @copydoc sign_only()
  65. * Signature for crypto drivers to implement for sign_only()
  66. * @see sign_only
  67. */
  68. typedef PEP_STATUS (*sign_only_t)(
  69. PEP_SESSION session, const char* fpr, const char *ptext,
  70. size_t psize, char **stext, size_t *ssize
  71. );
  72. /**
  73. * @copydoc delete_keypair()
  74. * Signature for crypto drivers to implement for delete_keypair()
  75. * @see delete_keypair()
  76. */
  77. typedef PEP_STATUS (*delete_keypair_t)(PEP_SESSION session, const char *fpr);
  78. /**
  79. * @copydoc export_key()
  80. * Signature for crypto drivers to implement for export_key()
  81. * @see export_key()
  82. */
  83. typedef PEP_STATUS (*export_key_t)(
  84. PEP_SESSION session, const char *fpr, char **key_data, size_t *size,
  85. bool secret
  86. );
  87. /**
  88. * @copydoc find_keys()
  89. * Signature for crypto drivers to implement for find_keys()
  90. * @see find_keys()
  91. */
  92. typedef PEP_STATUS (*find_keys_t)(
  93. PEP_SESSION session, const char *pattern, stringlist_t **keylist
  94. );
  95. /**
  96. * @copydoc generate_keypair()
  97. * Signature for crypto drivers to implement for generate_keypair()
  98. * @see generate_keypair()
  99. */
  100. typedef PEP_STATUS (*generate_keypair_t)(
  101. PEP_SESSION session, pEp_identity *identity
  102. );
  103. /**
  104. * @copydoc get_key_rating()
  105. * Signature for crypto drivers to implement for get_key_rating()
  106. * @see get_key_rating()
  107. */
  108. typedef PEP_STATUS (*get_key_rating_t)(
  109. PEP_SESSION session,
  110. const char *fpr,
  111. PEP_comm_type *comm_type
  112. );
  113. /**
  114. * @copydoc import_key()
  115. * Signature for crypto drivers to implement for import_key()
  116. * @see import_key()
  117. */
  118. typedef PEP_STATUS (*import_key_t)(PEP_SESSION session, const char *key_data,
  119. size_t size, identity_list **private_keys, stringlist_t** imported_keys,
  120. uint64_t* changed_key_index);
  121. /**
  122. * @copydoc recv_key()
  123. * Signature for crypto drivers to implement for recv_key()
  124. * @see recv_key()
  125. */
  126. typedef PEP_STATUS (*recv_key_t)(PEP_SESSION session, const char *pattern);
  127. /**
  128. * @copydoc send_key()
  129. * Signature for crypto drivers to implement for send_key()
  130. * @see send_key()
  131. */
  132. typedef PEP_STATUS (*send_key_t)(PEP_SESSION session, const char *pattern);
  133. /**
  134. * @copydoc renew_key()
  135. * Signature for crypto drivers to implement for renew_key()
  136. * @see renew_key()
  137. */
  138. typedef PEP_STATUS (*renew_key_t)(PEP_SESSION session, const char *fpr,
  139. const timestamp *ts);
  140. /**
  141. * @copydoc revoke_key()
  142. * Signature for crypto drivers to implement for revoke_key()
  143. * @see revoke_key()
  144. */
  145. typedef PEP_STATUS (*revoke_key_t)(PEP_SESSION session, const char *fpr,
  146. const char *reason);
  147. /**
  148. * @copydoc key_expired()
  149. * Signature for crypto drivers to implement for key_expired()
  150. * @see key_expired()
  151. */
  152. typedef PEP_STATUS (*key_expired_t)(PEP_SESSION session, const char *fpr,
  153. const time_t when, bool *expired);
  154. /**
  155. * @copydoc key_revoked()
  156. * Signature for crypto drivers to implement for key_revoked()
  157. * @see key_revoked()
  158. */
  159. typedef PEP_STATUS (*key_revoked_t)(PEP_SESSION session, const char *fpr,
  160. bool *revoked);
  161. /**
  162. * @copydoc key_created()
  163. * Signature for crypto drivers to implement for key_created()
  164. * @see key_created()
  165. */
  166. typedef PEP_STATUS (*key_created_t)(PEP_SESSION session, const char *fpr,
  167. time_t *created);
  168. /**
  169. * @copydoc binary_path()
  170. * Signature for crypto drivers to implement for binary_path()
  171. * @see binary_path()
  172. */
  173. typedef PEP_STATUS (*binary_path_t)(const char **path);
  174. /**
  175. * @copydoc contains_priv_key()
  176. * Signature for crypto drivers to implement for contains_priv_key()
  177. * @see contains_priv_key()
  178. */
  179. typedef PEP_STATUS (*contains_priv_key_t)(PEP_SESSION session, const char *fpr,
  180. bool *has_private);
  181. /**
  182. * @copydoc find_private_keys()
  183. * Signature for crypto drivers to implement for find_private_keys()
  184. * @see find_private_keys()
  185. */
  186. typedef PEP_STATUS (*find_private_keys_t)(
  187. PEP_SESSION session, const char *pattern, stringlist_t **keylist
  188. );
  189. /**
  190. * @copydoc config_cipher_suite()
  191. * Signature for crypto drivers to implement for config_cipher_suite()
  192. * @see config_cipher_suite()
  193. */
  194. typedef PEP_STATUS (*config_cipher_suite_t)(PEP_SESSION session,
  195. PEP_CIPHER_SUITE suite);
  196. /**
  197. * @struct PEP_cryptotech_t
  198. *
  199. * @brief TODO
  200. *
  201. */
  202. typedef struct _PEP_cryptotech_t {
  203. uint8_t id;
  204. // the following are default values; comm_type may vary with key length or b0rken crypto
  205. uint8_t unconfirmed_comm_type;
  206. uint8_t confirmed_comm_type;
  207. decrypt_and_verify_t decrypt_and_verify;
  208. verify_text_t verify_text;
  209. encrypt_and_sign_t encrypt_and_sign;
  210. encrypt_only_t encrypt_only;
  211. sign_only_t sign_only;
  212. delete_keypair_t delete_keypair;
  213. export_key_t export_key;
  214. find_keys_t find_keys;
  215. generate_keypair_t generate_keypair;
  216. get_key_rating_t get_key_rating;
  217. import_key_t import_key;
  218. recv_key_t recv_key;
  219. send_key_t send_key;
  220. renew_key_t renew_key;
  221. revoke_key_t revoke_key;
  222. key_expired_t key_expired;
  223. key_revoked_t key_revoked;
  224. key_created_t key_created;
  225. binary_path_t binary_path;
  226. contains_priv_key_t contains_priv_key;
  227. find_private_keys_t find_private_keys;
  228. config_cipher_suite_t config_cipher_suite;
  229. } PEP_cryptotech_t;
  230. extern PEP_cryptotech_t cryptotech[PEP_crypt__count];
  231. typedef uint64_t cryptotech_mask;
  232. /**
  233. * <!-- init_cryptotech() -->
  234. *
  235. * @brief TODO
  236. *
  237. * @param[in] session PEP_SESSION
  238. * @param[in] in_first bool
  239. *
  240. */
  241. PEP_STATUS init_cryptotech(PEP_SESSION session, bool in_first);
  242. /**
  243. * <!-- release_cryptotech() -->
  244. *
  245. * @brief TODO
  246. *
  247. * @param[in] session PEP_SESSION
  248. * @param[in] out_last bool
  249. *
  250. */
  251. void release_cryptotech(PEP_SESSION session, bool out_last);
  252. #endif