p≡p engine FORK
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.

1476 lines
52 KiB

8 years ago
8 years ago
7 years ago
8 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
6 years ago
6 years ago
6 years ago
6 years ago
4 years ago
6 years ago
8 years ago
6 years ago
8 years ago
8 years ago
8 years ago
4 years ago
4 years ago
4 years ago
3 years ago
8 years ago
4 years ago
4 years ago
8 years ago
8 years ago
4 years ago
8 years ago
4 years ago
8 years ago
4 years ago
4 years ago
8 years ago
8 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
3 years ago
8 years ago
8 years ago
8 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
3 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 years ago
6 years ago
8 years ago
8 years ago
7 years ago
7 years ago
8 years ago
8 years ago
6 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
6 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
4 years ago
8 years ago
  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. #pragma once
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #include <stddef.h>
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #include "dynamic_api.h"
  11. #include "stringlist.h"
  12. #include "stringpair.h"
  13. #include "labeled_int_list.h"
  14. #include "timestamp.h"
  15. #define PEP_VERSION "2.1" // pEp *protocol* version
  16. // RELEASE version this targets
  17. // (string: major.minor.patch)
  18. #define PEP_ENGINE_VERSION "2.1.0"
  19. // Numeric values of above:
  20. #define PEP_ENGINE_VERSION_MAJOR 2
  21. #define PEP_ENGINE_VERSION_MINOR 1
  22. #define PEP_ENGINE_VERSION_PATCH 0
  23. #define PEP_ENGINE_VERSION_RC 1
  24. #define PEP_OWN_USERID "pEp_own_userId"
  25. // pEp Engine API
  26. // caveat:
  27. // Unicode data has to be normalized to NFC before calling
  28. // UTF-8 strings are UTF-8 encoded C strings (zero terminated)
  29. struct _pEpSession;
  30. typedef struct _pEpSession * PEP_SESSION;
  31. typedef enum {
  32. PEP_STATUS_OK = 0,
  33. PEP_INIT_CANNOT_LOAD_CRYPTO_LIB = 0x0110,
  34. PEP_INIT_CRYPTO_LIB_INIT_FAILED = 0x0111,
  35. PEP_INIT_NO_CRYPTO_HOME = 0x0112,
  36. // PEP_INIT_NETPGP_INIT_FAILED = 0x0113,
  37. PEP_INIT_CANNOT_DETERMINE_CRYPTO_VERSION = 0x0114,
  38. PEP_INIT_UNSUPPORTED_CRYPTO_VERSION = 0x0115,
  39. PEP_INIT_CANNOT_CONFIG_CRYPTO_AGENT = 0x0116,
  40. PEP_INIT_SQLITE3_WITHOUT_MUTEX = 0x0120,
  41. PEP_INIT_CANNOT_OPEN_DB = 0x0121,
  42. PEP_INIT_CANNOT_OPEN_SYSTEM_DB = 0x0122,
  43. PEP_INIT_DB_DOWNGRADE_VIOLATION = 0x0123,
  44. PEP_UNKNOWN_DB_ERROR = 0x01ff,
  45. PEP_KEY_NOT_FOUND = 0x0201,
  46. PEP_KEY_HAS_AMBIG_NAME = 0x0202,
  47. PEP_GET_KEY_FAILED = 0x0203,
  48. PEP_CANNOT_EXPORT_KEY = 0x0204,
  49. PEP_CANNOT_EDIT_KEY = 0x0205,
  50. PEP_KEY_UNSUITABLE = 0x0206,
  51. PEP_MALFORMED_KEY_RESET_MSG = 0x0210,
  52. PEP_KEY_NOT_RESET = 0x0211,
  53. PEP_CANNOT_DELETE_KEY = 0x0212,
  54. PEP_KEY_IMPORTED = 0x0220,
  55. PEP_NO_KEY_IMPORTED = 0x0221,
  56. PEP_KEY_IMPORT_STATUS_UNKNOWN = 0x0222,
  57. PEP_SOME_KEYS_IMPORTED = 0x0223,
  58. PEP_CANNOT_FIND_IDENTITY = 0x0301,
  59. PEP_CANNOT_SET_PERSON = 0x0381,
  60. PEP_CANNOT_SET_PGP_KEYPAIR = 0x0382,
  61. PEP_CANNOT_SET_IDENTITY = 0x0383,
  62. PEP_CANNOT_SET_TRUST = 0x0384,
  63. PEP_KEY_BLACKLISTED = 0x0385,
  64. PEP_CANNOT_FIND_PERSON = 0x0386,
  65. PEP_CANNOT_SET_PEP_VERSION = 0X0387,
  66. PEP_CANNOT_FIND_ALIAS = 0x0391,
  67. PEP_CANNOT_SET_ALIAS = 0x0392,
  68. PEP_UNENCRYPTED = 0x0400,
  69. PEP_VERIFIED = 0x0401,
  70. PEP_DECRYPTED = 0x0402,
  71. PEP_DECRYPTED_AND_VERIFIED = 0x0403,
  72. PEP_DECRYPT_WRONG_FORMAT = 0x0404,
  73. PEP_DECRYPT_NO_KEY = 0x0405,
  74. PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH = 0x0406,
  75. PEP_VERIFY_NO_KEY = 0x0407,
  76. PEP_VERIFIED_AND_TRUSTED = 0x0408,
  77. PEP_CANNOT_REENCRYPT = 0x0409,
  78. PEP_VERIFY_SIGNER_KEY_REVOKED = 0x040a,
  79. PEP_CANNOT_DECRYPT_UNKNOWN = 0x04ff,
  80. PEP_TRUSTWORD_NOT_FOUND = 0x0501,
  81. PEP_TRUSTWORDS_FPR_WRONG_LENGTH = 0x0502,
  82. PEP_TRUSTWORDS_DUPLICATE_FPR = 0x0503,
  83. PEP_CANNOT_CREATE_KEY = 0x0601,
  84. PEP_CANNOT_SEND_KEY = 0x0602,
  85. PEP_PHRASE_NOT_FOUND = 0x0701,
  86. PEP_SEND_FUNCTION_NOT_REGISTERED = 0x0801,
  87. PEP_CONTRAINTS_VIOLATED = 0x0802,
  88. PEP_CANNOT_ENCODE = 0x0803,
  89. PEP_SYNC_NO_NOTIFY_CALLBACK = 0x0901,
  90. PEP_SYNC_ILLEGAL_MESSAGE = 0x0902,
  91. PEP_SYNC_NO_INJECT_CALLBACK = 0x0903,
  92. PEP_SYNC_NO_CHANNEL = 0x0904,
  93. PEP_SYNC_CANNOT_ENCRYPT = 0x0905,
  94. PEP_SYNC_NO_MESSAGE_SEND_CALLBACK = 0x0906,
  95. PEP_SYNC_CANNOT_START = 0x0907,
  96. PEP_CANNOT_INCREASE_SEQUENCE = 0x0971,
  97. PEP_STATEMACHINE_ERROR = 0x0980,
  98. PEP_NO_TRUST = 0x0981,
  99. PEP_STATEMACHINE_INVALID_STATE = 0x0982,
  100. PEP_STATEMACHINE_INVALID_EVENT = 0x0983,
  101. PEP_STATEMACHINE_INVALID_CONDITION = 0x0984,
  102. PEP_STATEMACHINE_INVALID_ACTION = 0x0985,
  103. PEP_STATEMACHINE_INHIBITED_EVENT = 0x0986,
  104. PEP_STATEMACHINE_CANNOT_SEND = 0x0987,
  105. PEP_DISTRIBUTION_ILLEGAL_MESSAGE = 0x1002,
  106. PEP_COMMIT_FAILED = 0xff01,
  107. PEP_MESSAGE_CONSUME = 0xff02,
  108. PEP_MESSAGE_IGNORE = 0xff03,
  109. PEP_CANNOT_CONFIG = 0xff04,
  110. PEP_RECORD_NOT_FOUND = -6,
  111. PEP_CANNOT_CREATE_TEMP_FILE = -5,
  112. PEP_ILLEGAL_VALUE = -4,
  113. PEP_BUFFER_TOO_SMALL = -3,
  114. PEP_OUT_OF_MEMORY = -2,
  115. PEP_UNKNOWN_ERROR = -1,
  116. PEP_VERSION_MISMATCH = -7,
  117. } PEP_STATUS;
  118. // messageToSend() - a message needs to be delivered by application
  119. //
  120. // parameters:
  121. // msg (in) message struct with message to send
  122. //
  123. // return value:
  124. // PEP_STATUS_OK or any other value on error
  125. //
  126. // caveat:
  127. // the ownership of msg goes to the callee
  128. struct _message;
  129. typedef PEP_STATUS (*messageToSend_t)(struct _message *msg);
  130. struct Sync_event;
  131. typedef struct Sync_event *SYNC_EVENT;
  132. // free_Sync_event() - free memory occupied by sync protocol message
  133. //
  134. // parameters:
  135. // ev (in) event to free
  136. DYNAMIC_API void free_Sync_event(SYNC_EVENT ev);
  137. // inject_sync_event - inject sync protocol message
  138. //
  139. // parameters:
  140. // ev (in) event to inject
  141. // management (in) application defined; usually a locked queue
  142. //
  143. // return value:
  144. // 0 if event could be stored successfully or nonzero otherwise
  145. //
  146. // caveat:
  147. // if ev is SHUTDOWN then the implementation has to be synchronous
  148. // and the shutdown must be immediate
  149. typedef int (*inject_sync_event_t)(SYNC_EVENT ev, void *management);
  150. // INIT_STATUS init() - initialize pEpEngine for a thread
  151. //
  152. // parameters:
  153. // session (out) init() allocates session memory and
  154. // returns a pointer as a handle
  155. // messageToSend (in) callback for sending message by the
  156. // application
  157. // inject_sync_event (in) callback for injecting a sync event
  158. //
  159. // return value:
  160. // PEP_STATUS_OK = 0 if init() succeeds
  161. // PEP_INIT_SQLITE3_WITHOUT_MUTEX if SQLite3 was compiled with
  162. // SQLITE_THREADSAFE 0
  163. // PEP_INIT_CANNOT_LOAD_CRYPTO_LIB if crypto lin cannot be found
  164. // PEP_INIT_CRYPTO_LIB_INIT_FAILED if CRYPTO_LIB init fails
  165. // PEP_INIT_CANNOT_OPEN_DB if user's management db cannot be
  166. // opened
  167. // PEP_INIT_CANNOT_OPEN_SYSTEM_DB if system's management db cannot be
  168. // opened
  169. //
  170. // caveat:
  171. // THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. release()
  172. // should be similarly guarded.
  173. //
  174. // the pointer is valid only if the return value is PEP_STATUS_OK
  175. // in other case a NULL pointer will be returned; a valid handle must
  176. // be released using release() when it's no longer needed
  177. //
  178. // the caller has to guarantee that the first call to this function
  179. // will succeed before further calls can be done
  180. //
  181. // messageToSend can only be null if no transport is application based
  182. // if transport system is not used it must not be NULL
  183. DYNAMIC_API PEP_STATUS init(
  184. PEP_SESSION *session,
  185. messageToSend_t messageToSend,
  186. inject_sync_event_t inject_sync_event
  187. );
  188. // void release() - release thread session handle
  189. //
  190. // parameters:
  191. // session (in) session handle to release
  192. //
  193. // caveat:
  194. // THE CALLER MUST GUARD THIS CALL EXTERNALLY WITH A MUTEX. init() should
  195. // be similarly guarded.
  196. //
  197. // the last release() can be called only when all other release() calls
  198. // are done
  199. DYNAMIC_API void release(PEP_SESSION session);
  200. // const stringlist_t* get_errorstack(PEP_SESSION) - get the error stack for that session, if any
  201. //
  202. // parameters:
  203. // session (in) session handle
  204. //
  205. // caveat:
  206. // To get a useful error stack you have to compile with -DDEBUG_ERRORSTACK
  207. // The error stack belongs to the session. Do no not change it!
  208. DYNAMIC_API const stringlist_t* get_errorstack(PEP_SESSION session);
  209. // void clear_errorstack(PEP_SESSION) - clear the error stack for that session, if any
  210. //
  211. // parameters:
  212. // session (in) session handle
  213. //
  214. DYNAMIC_API void clear_errorstack(PEP_SESSION session);
  215. // config_passive_mode() - enable passive mode
  216. //
  217. // parameters:
  218. // session (in) session handle
  219. // enable (in) flag if enabled or disabled
  220. DYNAMIC_API void config_passive_mode(PEP_SESSION session, bool enable);
  221. // config_unencrypted_subject() - disable subject encryption
  222. //
  223. // parameters:
  224. // session (in) session handle
  225. // enable (in) flag if enabled or disabled
  226. DYNAMIC_API void config_unencrypted_subject(PEP_SESSION session, bool enable);
  227. // config_use_only_own_private_keys() - enable passive mode
  228. //
  229. // parameters:
  230. // session (in) session handle
  231. // enable (in) flag if enabled or disabled
  232. DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session, bool enable);
  233. // config_service_log() - log more for service purposes
  234. //
  235. // session (in) session handle
  236. // enable (in) flag if enabled or disabled
  237. DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable);
  238. typedef enum {
  239. PEP_CIPHER_SUITE_DEFAULT = 0,
  240. PEP_CIPHER_SUITE_CV25519 = 1,
  241. PEP_CIPHER_SUITE_P256 = 2,
  242. PEP_CIPHER_SUITE_P384 = 3,
  243. PEP_CIPHER_SUITE_P521 = 4,
  244. PEP_CIPHER_SUITE_RSA2K = 5,
  245. PEP_CIPHER_SUITE_RSA3K = 6,
  246. PEP_CIPHER_SUITE_RSA4K = 7,
  247. PEP_CIPHER_SUITE_RSA8K = 8
  248. } PEP_CIPHER_SUITE;
  249. // config_cipher_suite() - cipher suite being used when encrypting
  250. //
  251. // parameters:
  252. // session (in) session handle
  253. // cipher_suite (in) cipher suite to use
  254. //
  255. // return value:
  256. // PEP_STATUS_OK cipher suite configured
  257. // PEP_CANNOT_CONFIG configuration failed; falling back to default
  258. //
  259. // caveat: the default ciphersuite for a crypt tech implementation is
  260. // implementation defined
  261. DYNAMIC_API PEP_STATUS config_cipher_suite(PEP_SESSION session,
  262. PEP_CIPHER_SUITE suite);
  263. // decrypt_and_verify() - decrypt and/or verify a message
  264. //
  265. // parameters:
  266. // session (in) session handle
  267. // ctext (in) cipher text to decrypt and/or verify
  268. // csize (in) size of cipher text
  269. // dsigtext (in) if extant, *detached* signature text for this
  270. // message (or NULL if not)
  271. // dsize (in) size of *detached* signature text for this
  272. // message (0, if no detached sig exists)
  273. // ptext (out) pointer to internal buffer with plain text
  274. // psize (out) size of plain text
  275. // keylist (out) list of key ids which where used to encrypt
  276. // filename_ptr (out) mails produced by certain PGP implementations
  277. // may return a decrypted filename here for attachments.
  278. // Externally, this can generally be NULL, and is an optional
  279. // parameter.
  280. //
  281. // return value:
  282. // PEP_UNENCRYPTED message was unencrypted and not signed
  283. // PEP_VERIFIED message was unencrypted, signature matches
  284. // PEP_DECRYPTED message is decrypted now, no signature
  285. // PEP_DECRYPTED_AND_VERIFIED message is decrypted now and verified
  286. // PEP_DECRYPT_WRONG_FORMAT message has wrong format to handle
  287. // PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
  288. // PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
  289. //
  290. // caveat:
  291. // the ownerships of ptext as well as keylist are going to the caller
  292. // the caller must use free() (or an Windoze pEp_free()) and
  293. // free_stringlist() to free them
  294. //
  295. // if this function failes an error message may be the first element of
  296. // keylist and the other elements may be the keys used for encryption
  297. DYNAMIC_API PEP_STATUS decrypt_and_verify(
  298. PEP_SESSION session, const char *ctext, size_t csize,
  299. const char *dsigtext, size_t dsigsize,
  300. char **ptext, size_t *psize, stringlist_t **keylist,
  301. char ** filename_ptr
  302. );
  303. // verify_text() - verfy plain text with a digital signature
  304. //
  305. // parameters:
  306. // session (in) session handle
  307. // text (in) text to verify
  308. // size (in) size of text
  309. // signature (in) signature text
  310. // sig_size (in) size of signature
  311. // keylist (out) list of key ids which where used to encrypt or NULL on
  312. // error
  313. //
  314. // return value:
  315. // PEP_VERIFIED message was unencrypted, signature matches
  316. // PEP_DECRYPT_NO_KEY key not available to decrypt and/or verify
  317. // PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH wrong signature
  318. DYNAMIC_API PEP_STATUS verify_text(
  319. PEP_SESSION session, const char *text, size_t size,
  320. const char *signature, size_t sig_size, stringlist_t **keylist
  321. );
  322. // encrypt_and_sign() - encrypt and sign a message
  323. //
  324. // parameters:
  325. // session (in) session handle
  326. // keylist (in) list of key ids to encrypt with as C strings
  327. // ptext (in) plain text to decrypt and/or verify
  328. // psize (in) size of plain text
  329. // ctext (out) pointer to internal buffer with cipher text
  330. // csize (out) size of cipher text
  331. //
  332. // return value:
  333. // PEP_STATUS_OK = 0 encryption and signing succeeded
  334. // PEP_KEY_NOT_FOUND at least one of the recipient keys
  335. // could not be found
  336. // PEP_KEY_HAS_AMBIG_NAME at least one of the recipient keys has
  337. // an ambiguous name
  338. // PEP_GET_KEY_FAILED cannot retrieve key
  339. //
  340. // caveat:
  341. // the ownership of ctext is going to the caller
  342. // the caller is responsible to free() it (on Windoze use pEp_free())
  343. // the first key in keylist is being used to sign the message
  344. // this implies there has to be a private key for that keypair
  345. DYNAMIC_API PEP_STATUS encrypt_and_sign(
  346. PEP_SESSION session, const stringlist_t *keylist, const char *ptext,
  347. size_t psize, char **ctext, size_t *csize
  348. );
  349. DYNAMIC_API void set_debug_color(PEP_SESSION session, int ansi_color);
  350. // log_event() - log a user defined event defined by UTF-8 encoded strings into
  351. // management log
  352. //
  353. // parameters:
  354. // session (in) session handle
  355. // title (in) C string with event name
  356. // entity (in) C string with name of entity which is logging
  357. // description (in) C string with long description for event or NULL if
  358. // omitted
  359. // comment (in) C string with user defined comment or NULL if
  360. // omitted
  361. //
  362. // return value:
  363. // PEP_STATUS_OK log entry created
  364. DYNAMIC_API PEP_STATUS log_event(
  365. PEP_SESSION session,
  366. const char *title,
  367. const char *entity,
  368. const char *description,
  369. const char *comment
  370. );
  371. DYNAMIC_API PEP_STATUS log_service(PEP_SESSION session, const char *title,
  372. const char *entity, const char *description, const char *comment);
  373. #define _STR_(x) #x
  374. #define _D_STR_(x) _STR_(x)
  375. #define S_LINE _D_STR_(__LINE__)
  376. #define SERVICE_LOG(session, title, entity, desc) \
  377. log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
  378. DYNAMIC_API void _service_error_log(PEP_SESSION session, const char *entity,
  379. PEP_STATUS status, const char *where);
  380. #define SERVICE_ERROR_LOG(session, entity, status) \
  381. _service_error_log((session), (entity), (status), __FILE__ ":" S_LINE)
  382. // trustword() - get the corresponding trustword for a 16 bit value
  383. //
  384. // parameters:
  385. // session (in) session handle
  386. // value (in) value to find a trustword for
  387. // lang (in) C string with ISO 639-1 language code
  388. // word (out) pointer to C string with trustword UTF-8 encoded
  389. // NULL if language is not supported or trustword
  390. // wordlist is damaged or unavailable
  391. // wsize (out) length of trustword
  392. //
  393. // return value:
  394. // PEP_STATUS_OK trustword retrieved
  395. // PEP_TRUSTWORD_NOT_FOUND trustword not found
  396. //
  397. // caveat:
  398. // the word pointer goes to the ownership of the caller
  399. // the caller is responsible to free() it (on Windoze use pEp_free())
  400. DYNAMIC_API PEP_STATUS trustword(
  401. PEP_SESSION session, uint16_t value, const char *lang,
  402. char **word, size_t *wsize
  403. );
  404. // trustwords() - get trustwords for a string of hex values of a fingerprint
  405. //
  406. // parameters:
  407. // session (in) session handle
  408. // fingerprint (in) C string with hex values to find trustwords for
  409. // lang (in) C string with ISO 639-1 language code
  410. // words (out) pointer to C string with trustwords UTF-8 encoded,
  411. // separated by a blank each
  412. // NULL if language is not supported or trustword
  413. // wordlist is damaged or unavailable
  414. // wsize (out) length of trustwords string
  415. // max_words (in) only generate a string with max_words;
  416. // if max_words == 0 there is no such limit
  417. //
  418. // return value:
  419. // PEP_STATUS_OK trustwords retrieved
  420. // PEP_OUT_OF_MEMORY out of memory
  421. // PEP_TRUSTWORD_NOT_FOUND at least one trustword not found
  422. //
  423. // caveat:
  424. // the word pointer goes to the ownership of the caller
  425. // the caller is responsible to free() it (on Windoze use pEp_free())
  426. //
  427. // DON'T USE THIS FUNCTION FROM HIGH LEVEL LANGUAGES!
  428. //
  429. // Better implement a simple one in the adapter yourself using trustword(), and
  430. // return a list of trustwords.
  431. // This function is provided for being used by C and C++ programs only.
  432. DYNAMIC_API PEP_STATUS trustwords(
  433. PEP_SESSION session, const char *fingerprint, const char *lang,
  434. char **words, size_t *wsize, int max_words
  435. );
  436. // TODO: increase versions in pEp.asn1 if rating changes
  437. typedef enum _PEP_comm_type {
  438. PEP_ct_unknown = 0,
  439. // range 0x01 to 0x09: no encryption, 0x0a to 0x0e: nothing reasonable
  440. PEP_ct_no_encryption = 0x01, // generic
  441. PEP_ct_no_encrypted_channel = 0x02,
  442. PEP_ct_key_not_found = 0x03,
  443. PEP_ct_key_expired = 0x04,
  444. PEP_ct_key_revoked = 0x05,
  445. PEP_ct_key_b0rken = 0x06,
  446. PEP_ct_key_expired_but_confirmed = 0x07, // NOT with confirmed bit. Just retaining info here in case of renewal.
  447. PEP_ct_my_key_not_included = 0x09,
  448. PEP_ct_security_by_obscurity = 0x0a,
  449. PEP_ct_b0rken_crypto = 0x0b,
  450. PEP_ct_key_too_short = 0x0c,
  451. PEP_ct_compromised = 0x0e, // known compromised connection
  452. PEP_ct_compromized = 0x0e, // deprecated misspelling
  453. PEP_ct_mistrusted = 0x0f, // known mistrusted key
  454. // range 0x10 to 0x3f: unconfirmed encryption
  455. PEP_ct_unconfirmed_encryption = 0x10, // generic
  456. PEP_ct_OpenPGP_weak_unconfirmed = 0x11, // RSA 1024 is weak
  457. PEP_ct_to_be_checked = 0x20, // generic
  458. PEP_ct_SMIME_unconfirmed = 0x21,
  459. PEP_ct_CMS_unconfirmed = 0x22,
  460. PEP_ct_strong_but_unconfirmed = 0x30, // generic
  461. PEP_ct_OpenPGP_unconfirmed = 0x38, // key at least 2048 bit RSA or EC
  462. PEP_ct_OTR_unconfirmed = 0x3a,
  463. // range 0x40 to 0x7f: unconfirmed encryption and anonymization
  464. PEP_ct_unconfirmed_enc_anon = 0x40, // generic
  465. PEP_ct_pEp_unconfirmed = 0x7f,
  466. PEP_ct_confirmed = 0x80, // this bit decides if trust is confirmed
  467. // range 0x81 to 0x8f: reserved
  468. // range 0x90 to 0xbf: confirmed encryption
  469. PEP_ct_confirmed_encryption = 0x90, // generic
  470. PEP_ct_OpenPGP_weak = 0x91, // RSA 1024 is weak (unused)
  471. PEP_ct_to_be_checked_confirmed = 0xa0, // generic
  472. PEP_ct_SMIME = 0xa1,
  473. PEP_ct_CMS = 0xa2,
  474. PEP_ct_strong_encryption = 0xb0, // generic
  475. PEP_ct_OpenPGP = 0xb8, // key at least 2048 bit RSA or EC
  476. PEP_ct_OTR = 0xba,
  477. // range 0xc0 to 0xff: confirmed encryption and anonymization
  478. PEP_ct_confirmed_enc_anon = 0xc0, // generic
  479. PEP_ct_pEp = 0xff
  480. } PEP_comm_type;
  481. typedef enum _identity_flags {
  482. // the first octet flags are app defined settings
  483. PEP_idf_not_for_sync = 0x0001, // don't use this identity for sync
  484. PEP_idf_list = 0x0002, // identity of list of persons
  485. // the second octet flags are calculated
  486. PEP_idf_devicegroup = 0x0100 // identity of a device group member
  487. } identity_flags;
  488. typedef unsigned int identity_flags_t;
  489. // typedef enum _keypair_flags {
  490. // } keypair_flags;
  491. typedef unsigned int keypair_flags_t;
  492. typedef struct _pEp_identity {
  493. char *address; // C string with address UTF-8 encoded
  494. char *fpr; // C string with fingerprint UTF-8 encoded
  495. char *user_id; // C string with user ID UTF-8 encoded
  496. // user_id MIGHT be set to "pEp_own_userId"
  497. // (use PEP_OWN_USERID preprocessor define)
  498. // if this is own user's identity.
  499. // But it is not REQUIRED to be.
  500. char *username; // C string with user name UTF-8 encoded
  501. PEP_comm_type comm_type; // type of communication with this ID
  502. char lang[3]; // language of conversation
  503. // ISO 639-1 ALPHA-2, last byte is 0
  504. bool me; // if this is the local user herself/himself
  505. unsigned int major_ver; // highest version of pEp message received, if any
  506. unsigned int minor_ver; // highest version of pEp message received, if any
  507. identity_flags_t flags; // identity_flag1 | identity_flag2 | ...
  508. } pEp_identity;
  509. typedef struct _identity_list {
  510. pEp_identity *ident;
  511. struct _identity_list *next;
  512. } identity_list;
  513. // new_identity() - allocate memory and set the string and size fields
  514. //
  515. // parameters:
  516. // address (in) UTF-8 string or NULL
  517. // fpr (in) UTF-8 string or NULL
  518. // user_id (in) UTF-8 string or NULL
  519. // username (in) UTF-8 string or NULL
  520. //
  521. // return value:
  522. // pEp_identity struct or NULL if out of memory
  523. //
  524. // caveat:
  525. // the strings are copied; the original strings are still being owned by
  526. // the caller
  527. DYNAMIC_API pEp_identity *new_identity(
  528. const char *address, const char *fpr, const char *user_id,
  529. const char *username
  530. );
  531. // identity_dup() - allocate memory and duplicate
  532. //
  533. // parameters:
  534. // src (in) identity to duplicate
  535. //
  536. // return value:
  537. // pEp_identity struct or NULL if out of memory
  538. //
  539. // caveat:
  540. // the strings are copied; the original strings are still being owned by
  541. // the caller
  542. DYNAMIC_API pEp_identity *identity_dup(const pEp_identity *src);
  543. // free_identity() - free all memory being occupied by a pEp_identity struct
  544. //
  545. // parameters:
  546. // identity (in) struct to release
  547. //
  548. // caveat:
  549. // not only the struct but also all string memory referenced by the
  550. // struct is being freed; all pointers inside are invalid afterwards
  551. DYNAMIC_API void free_identity(pEp_identity *identity);
  552. // get_identity() - get identity information
  553. //
  554. // parameters:
  555. // session (in) session handle
  556. // address (in) C string with communication address, UTF-8 encoded
  557. // user_id (in) unique C string to identify person that identity
  558. // is refering to
  559. // identity (out) pointer to pEp_identity structure with results or
  560. // NULL if failure
  561. //
  562. // caveat:
  563. // address and user_id are being copied; the original strings remains in
  564. // the ownership of the caller
  565. // the resulting pEp_identity structure goes to the ownership of the
  566. // caller and has to be freed with free_identity() when not in use any
  567. // more
  568. DYNAMIC_API PEP_STATUS get_identity(
  569. PEP_SESSION session,
  570. const char *address,
  571. const char *user_id,
  572. pEp_identity **identity
  573. );
  574. PEP_STATUS replace_identities_fpr(PEP_SESSION session,
  575. const char* old_fpr,
  576. const char* new_fpr);
  577. // set_identity() - set identity information
  578. //
  579. // parameters:
  580. // session (in) session handle
  581. // identity (in) pointer to pEp_identity structure
  582. //
  583. // return value:
  584. // PEP_STATUS_OK = 0 encryption and signing succeeded
  585. // PEP_CANNOT_SET_PERSON writing to table person failed
  586. // PEP_CANNOT_SET_PGP_KEYPAIR writing to table pgp_keypair failed
  587. // PEP_CANNOT_SET_IDENTITY writing to table identity failed
  588. // PEP_COMMIT_FAILED SQL commit failed
  589. //
  590. // caveat:
  591. // address, fpr, user_id and username must be given
  592. DYNAMIC_API PEP_STATUS set_identity(
  593. PEP_SESSION session, const pEp_identity *identity
  594. );
  595. // get_default own_userid() - get the user_id of the own user
  596. //
  597. // parameters:
  598. // session (in) session handle
  599. // userid (out) own user id (if it exists)
  600. //
  601. // return value:
  602. // PEP_STATUS_OK = 0 userid was found
  603. // PEP_CANNOT_FIND_IDENTITY no own_user found in the DB
  604. // PEP_UNKNOWN_ERROR results were returned, but no ID
  605. // found (no reason this should ever occur)
  606. // caveat:
  607. // userid will be NULL if not found; otherwise, returned string
  608. // belongs to the caller.
  609. DYNAMIC_API PEP_STATUS get_default_own_userid(
  610. PEP_SESSION session,
  611. char** userid
  612. );
  613. // get_userid_alias_default() - get the default user_id which corresponds
  614. // to an alias
  615. // parameters:
  616. // session (in) session handle
  617. // alias_id (in) the user_id which may be an alias for a default id
  618. // default_id (out) the default id for this alias, if the alias
  619. // is in the DB as an alias, else NULL
  620. // return value:
  621. // PEP_STATUS_OK = 0 userid was found
  622. // PEP_CANNOT_FIND_ALIAS this userid is not listed as an
  623. // alias in the DB
  624. // PEP_UNKNOWN_ERROR results were returned, but no ID
  625. // found (no reason this should ever occur)
  626. // caveat:
  627. // default_id will be NULL if not found; otherwise, returned string
  628. // belongs to the caller.
  629. // also, current implementation does NOT check to see if this userid
  630. // IS a default.
  631. DYNAMIC_API PEP_STATUS get_userid_alias_default(
  632. PEP_SESSION session,
  633. const char* alias_id,
  634. char** default_id);
  635. // set_userid_alias() - set an alias to correspond to a default id
  636. // parameters:
  637. // session (in) session handle
  638. // default_id (in) the default id for this alias. This must
  639. // correspond to the default user_id for an
  640. // entry in the person (user) table.
  641. // alias_id (in) the alias to be set for this default id
  642. // return value:
  643. // PEP_STATUS_OK = 0 userid was found
  644. // PEP_CANNOT_SET_ALIAS there was an error setting this
  645. DYNAMIC_API PEP_STATUS set_userid_alias (
  646. PEP_SESSION session,
  647. const char* default_id,
  648. const char* alias_id);
  649. // set_identity_flags() - update identity flags on existing identity
  650. //
  651. // parameters:
  652. // session (in) session handle
  653. // identity (in,out) pointer to pEp_identity structure
  654. // flags (in) new value for flags
  655. //
  656. // return value:
  657. // PEP_STATUS_OK = 0 encryption and signing succeeded
  658. // PEP_CANNOT_SET_IDENTITY update of identity failed
  659. //
  660. // caveat:
  661. // address and user_id must be given in identity
  662. DYNAMIC_API PEP_STATUS set_identity_flags(
  663. PEP_SESSION session,
  664. pEp_identity *identity,
  665. identity_flags_t flags
  666. );
  667. // unset_identity_flags() - update identity flags on existing identity
  668. //
  669. // parameters:
  670. // session (in) session handle
  671. // identity (in,out) pointer to pEp_identity structure
  672. // flags (in) new value for flags
  673. //
  674. // return value:
  675. // PEP_STATUS_OK = 0 encryption and signing succeeded
  676. // PEP_CANNOT_SET_IDENTITY update of identity failed
  677. //
  678. // caveat:
  679. // address and user_id must be given in identity
  680. DYNAMIC_API PEP_STATUS unset_identity_flags(
  681. PEP_SESSION session,
  682. pEp_identity *identity,
  683. identity_flags_t flags
  684. );
  685. // mark_as_compromised() - mark key in trust db as compromised
  686. //
  687. // parameters:
  688. // session (in) session handle
  689. // fpr (in) fingerprint of key to mark
  690. DYNAMIC_API PEP_STATUS mark_as_compromised(
  691. PEP_SESSION session,
  692. const char *fpr
  693. );
  694. // mark_as_compromized() - deprecated to fix misspelling. Please move to
  695. // mark_as_compromised();
  696. DYNAMIC_API PEP_STATUS mark_as_compromized(
  697. PEP_SESSION session,
  698. const char *fpr
  699. );
  700. // generate_keypair() - generate a new key pair and add it to the key ring
  701. //
  702. // parameters:
  703. // session (in) session handle
  704. // identity (inout) pointer to pEp_identity structure
  705. //
  706. // return value:
  707. // PEP_STATUS_OK = 0 encryption and signing succeeded
  708. // PEP_ILLEGAL_VALUE illegal values for identity fields given
  709. // PEP_CANNOT_CREATE_KEY key engine is on strike
  710. //
  711. // caveat:
  712. // address must be set to UTF-8 string
  713. // the fpr field must be set to NULL
  714. // username field must either be NULL or be a UTF8-string conforming
  715. // to RFC4880 for PGP uid usernames
  716. //
  717. // this function allocates a string and sets set fpr field of identity
  718. // the caller is responsible to call free() for that string or use
  719. // free_identity() on the struct
  720. DYNAMIC_API PEP_STATUS generate_keypair(
  721. PEP_SESSION session, pEp_identity *identity
  722. );
  723. // delete_keypair() - delete a public key or a key pair from the key ring
  724. //
  725. // parameters:
  726. // session (in) session handle
  727. // fpr (in) C string with key id or fingerprint of the
  728. // public key
  729. //
  730. // return value:
  731. // PEP_STATUS_OK = 0 key was successfully deleted
  732. // PEP_KEY_NOT_FOUND key not found
  733. // PEP_ILLEGAL_VALUE not a valid key id or fingerprint
  734. // PEP_KEY_HAS_AMBIG_NAME fpr does not uniquely identify a key
  735. // PEP_OUT_OF_MEMORY out of memory
  736. DYNAMIC_API PEP_STATUS delete_keypair(PEP_SESSION session, const char *fpr);
  737. // import_key() - import key from data
  738. //
  739. // parameters:
  740. // session (in) session handle
  741. // key_data (in) key data, i.e. ASCII armored OpenPGP key
  742. // size (in) amount of data to handle
  743. // private_keys (out) list of private keys that have been imported
  744. //
  745. // return value:
  746. // PEP_STATUS_OK = 0 key was successfully imported
  747. // PEP_OUT_OF_MEMORY out of memory
  748. // PEP_ILLEGAL_VALUE there is no key data to import
  749. //
  750. // caveat:
  751. // private_keys goes to the ownership of the caller
  752. // private_keys can be left NULL, it is then ignored
  753. DYNAMIC_API PEP_STATUS import_key(
  754. PEP_SESSION session,
  755. const char *key_data,
  756. size_t size,
  757. identity_list **private_keys
  758. );
  759. // export_key() - export ascii armored key
  760. //
  761. // parameters:
  762. // session (in) session handle
  763. // fpr (in) key id or fingerprint of key
  764. // key_data (out) ASCII armored OpenPGP key
  765. // size (out) amount of data to handle
  766. //
  767. // return value:
  768. // PEP_STATUS_OK = 0 key was successfully exported
  769. // PEP_OUT_OF_MEMORY out of memory
  770. // PEP_KEY_NOT_FOUND key not found
  771. //
  772. // caveat:
  773. // the key_data goes to the ownership of the caller
  774. // the caller is responsible to free() it (on Windoze use pEp_free())
  775. DYNAMIC_API PEP_STATUS export_key(
  776. PEP_SESSION session, const char *fpr, char **key_data, size_t *size
  777. );
  778. // export_secret_key() - export secret key ascii armored
  779. //
  780. // parameters:
  781. // session (in) session handle
  782. // fpr (in) fingerprint of key, at least 16 hex digits
  783. // key_data (out) ASCII armored OpenPGP secret key
  784. // size (out) amount of data to handle
  785. //
  786. // return value:
  787. // PEP_STATUS_OK = 0 key was successfully exported
  788. // PEP_OUT_OF_MEMORY out of memory
  789. // PEP_KEY_NOT_FOUND key not found
  790. // PEP_CANNOT_EXPORT_KEY cannot export secret key (i.e. it's on an HKS)
  791. //
  792. // caveat:
  793. // the key_data goes to the ownership of the caller
  794. // the caller is responsible to free() it (on Windoze use pEp_free())
  795. // beware of leaking secret key data - overwrite it in memory after use
  796. DYNAMIC_API PEP_STATUS export_secret_key(
  797. PEP_SESSION session, const char *fpr, char **key_data, size_t *size
  798. );
  799. // export_secrect_key() - deprecated misspelled function. Please replace with
  800. // export_secret_key
  801. DYNAMIC_API PEP_STATUS export_secrect_key(
  802. PEP_SESSION session, const char *fpr, char **key_data, size_t *size
  803. );
  804. // recv_key() - update key(s) from keyserver
  805. //
  806. // parameters:
  807. // session (in) session handle
  808. // pattern (in) key id, user id or address to search for as
  809. // UTF-8 string
  810. DYNAMIC_API PEP_STATUS recv_key(PEP_SESSION session, const char *pattern);
  811. // find_keys() - find keys in keyring
  812. //
  813. // parameters:
  814. // session (in) session handle
  815. // pattern (in) key id, user id or address to search for as
  816. // UTF-8 string
  817. // keylist (out) list of fingerprints found or NULL on error
  818. //
  819. // caveat:
  820. // the ownerships of keylist isgoing to the caller
  821. // the caller must use free_stringlist() to free it
  822. DYNAMIC_API PEP_STATUS find_keys(
  823. PEP_SESSION session, const char *pattern, stringlist_t **keylist
  824. );
  825. // send_key() - send key(s) to keyserver
  826. //
  827. // parameters:
  828. // session (in) session handle
  829. // pattern (in) key id, user id or address to search for as
  830. // UTF-8 string
  831. DYNAMIC_API PEP_STATUS send_key(PEP_SESSION session, const char *pattern);
  832. // pEp_free() - free memory allocated by pEp engine
  833. //
  834. // parameters:
  835. // p (in) pointer to free
  836. //
  837. // The reason for this function is that heap management can be a pretty
  838. // complex task with Windoze. This free() version calls the free()
  839. // implementation of the C runtime library which was used to build pEp engine,
  840. // so you're using the correct heap. For more information, see:
  841. // <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
  842. DYNAMIC_API void pEp_free(void *p);
  843. // pEp_realloc() - reallocate memory allocated by pEp engine
  844. //
  845. // parameters:
  846. // p (in) pointer to free
  847. // size (in) new memory size
  848. //
  849. // returns:
  850. // pointer to allocated memory
  851. //
  852. // The reason for this function is that heap management can be a pretty
  853. // complex task with Windoze. This realloc() version calls the realloc()
  854. // implementation of the C runtime library which was used to build pEp engine,
  855. // so you're using the correct heap. For more information, see:
  856. // <http://msdn.microsoft.com/en-us/library/windows/desktop/aa366711(v=vs.85).aspx>
  857. DYNAMIC_API void *pEp_realloc(void *p, size_t size);
  858. // get_trust() - get the trust level a key has for a person
  859. //
  860. // parameters:
  861. // session (in) session handle
  862. // identity (inout) user_id and fpr to check as UTF-8 strings (in)
  863. // comm_type as result (out)
  864. //
  865. // this function modifies the given identity struct; the struct remains in
  866. // the ownership of the caller
  867. // if the trust level cannot be determined identity->comm_type is set
  868. // to PEP_ct_unknown
  869. DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity);
  870. PEP_STATUS set_trust(PEP_SESSION session,
  871. pEp_identity* identity);
  872. PEP_STATUS update_trust_for_fpr(PEP_SESSION session,
  873. const char* fpr,
  874. PEP_comm_type comm_type);
  875. // least_trust() - get the least known trust level for a key in the database
  876. //
  877. // parameters:
  878. // session (in) session handle
  879. // fpr (in) fingerprint of key to check
  880. // comm_type (out) least comm_type as result (out)
  881. //
  882. // if the trust level cannot be determined comm_type is set to PEP_ct_unknown
  883. DYNAMIC_API PEP_STATUS least_trust(
  884. PEP_SESSION session,
  885. const char *fpr,
  886. PEP_comm_type *comm_type
  887. );
  888. // get_key_rating() - get the rating a bare key has
  889. //
  890. // parameters:
  891. // session (in) session handle
  892. // fpr (in) unique identifyer for key as UTF-8 string
  893. // comm_type (out) key rating
  894. //
  895. // if an error occurs, *comm_type is set to PEP_ct_unknown and an error
  896. // is returned
  897. DYNAMIC_API PEP_STATUS get_key_rating(
  898. PEP_SESSION session,
  899. const char *fpr,
  900. PEP_comm_type *comm_type
  901. );
  902. // renew_key() - renew an expired key
  903. //
  904. // parameters:
  905. // session (in) session handle
  906. // fpr (in) ID of key to renew as UTF-8 string
  907. // ts (in) timestamp when key should expire or NULL for
  908. // default
  909. DYNAMIC_API PEP_STATUS renew_key(
  910. PEP_SESSION session,
  911. const char *fpr,
  912. const timestamp *ts
  913. );
  914. // revoke_key() - revoke a key
  915. //
  916. // parameters:
  917. // session (in) session handle
  918. // fpr (in) ID of key to revoke as UTF-8 string
  919. // reason (in) text with reason for revoke as UTF-8 string
  920. // or NULL if reason unknown
  921. //
  922. // caveat:
  923. // reason text must not include empty lines
  924. // this function is meant for internal use only; better use
  925. // key_mistrusted() of keymanagement API
  926. DYNAMIC_API PEP_STATUS revoke_key(
  927. PEP_SESSION session,
  928. const char *fpr,
  929. const char *reason
  930. );
  931. // key_expired() - flags if a key is already expired
  932. //
  933. // parameters:
  934. // session (in) session handle
  935. // fpr (in) ID of key to check as UTF-8 string
  936. // when (in) UTC time of when should expiry be considered
  937. // expired (out) flag if key expired
  938. DYNAMIC_API PEP_STATUS key_expired(
  939. PEP_SESSION session,
  940. const char *fpr,
  941. const time_t when,
  942. bool *expired
  943. );
  944. // key_revoked() - flags if a key is already revoked
  945. //
  946. // parameters:
  947. // session (in) session handle
  948. // fpr (in) ID of key to check as UTF-8 string
  949. // revoked (out) flag if key revoked
  950. DYNAMIC_API PEP_STATUS key_revoked(
  951. PEP_SESSION session,
  952. const char *fpr,
  953. bool *revoked
  954. );
  955. PEP_STATUS get_key_userids(
  956. PEP_SESSION session,
  957. const char* fpr,
  958. stringlist_t** keylist
  959. );
  960. // get_crashdump_log() - get the last log messages out
  961. //
  962. // parameters:
  963. // session (in) session handle
  964. // maxlines (in) maximum number of lines (0 for default)
  965. // logdata (out) logdata as string in double quoted CSV format
  966. // column1 is title
  967. // column2 is entity
  968. // column3 is description
  969. // column4 is comment
  970. //
  971. // caveat:
  972. // the ownership of logdata goes to the caller
  973. DYNAMIC_API PEP_STATUS get_crashdump_log(
  974. PEP_SESSION session,
  975. int maxlines,
  976. char **logdata
  977. );
  978. // get_languagelist() - get the list of languages
  979. //
  980. // parameters:
  981. // session (in) session handle
  982. // languages (out) languages as string in double quoted CSV format
  983. // column 1 is the ISO 639-1 language code
  984. // column 2 is the name of the language
  985. //
  986. // caveat:
  987. // the ownership of languages goes to the caller
  988. DYNAMIC_API PEP_STATUS get_languagelist(
  989. PEP_SESSION session,
  990. char **languages
  991. );
  992. // get_phrase() - get phrase in a dedicated language through i18n
  993. //
  994. // parameters:
  995. // session (in) session handle
  996. // lang (in) C string with ISO 639-1 language code
  997. // phrase_id (in) id of phrase in i18n
  998. // phrase (out) phrase as UTF-8 string
  999. //
  1000. // caveat:
  1001. // the ownership of phrase goes to the caller
  1002. DYNAMIC_API PEP_STATUS get_phrase(
  1003. PEP_SESSION session,
  1004. const char *lang,
  1005. int phrase_id,
  1006. char **phrase
  1007. );
  1008. // sequence_value() - raise the value of a named sequence and retrieve it
  1009. //
  1010. // parameters:
  1011. // session (in) session handle
  1012. // name (in) name of sequence
  1013. // value (out) value of sequence
  1014. //
  1015. // returns:
  1016. // PEP_STATUS_OK no error, not own sequence
  1017. // PEP_SEQUENCE_VIOLATED if sequence violated
  1018. // PEP_CANNOT_INCREASE_SEQUENCE if sequence cannot be increased
  1019. // PEP_OWN_SEQUENCE if own sequence
  1020. DYNAMIC_API PEP_STATUS sequence_value(
  1021. PEP_SESSION session,
  1022. const char *name,
  1023. int32_t *value
  1024. );
  1025. // set_revoked() - records relation between a revoked key and its replacement
  1026. //
  1027. // parameters:
  1028. // session (in) session handle
  1029. // revoked_fpr (in) revoked fingerprint
  1030. // replacement_fpr (in) replacement key fingerprint
  1031. // revocation_date (in) revocation date
  1032. DYNAMIC_API PEP_STATUS set_revoked(
  1033. PEP_SESSION session,
  1034. const char *revoked_fpr,
  1035. const char *replacement_fpr,
  1036. const uint64_t revocation_date
  1037. );
  1038. // get_revoked() - find revoked key that may have been replaced by given key, if any
  1039. //
  1040. // parameters:
  1041. // session (in) session handle
  1042. // fpr (in) given fingerprint
  1043. // revoked_fpr (out) revoked fingerprint
  1044. // revocation_date (out) revocation date
  1045. DYNAMIC_API PEP_STATUS get_revoked(
  1046. PEP_SESSION session,
  1047. const char *fpr,
  1048. char **revoked_fpr,
  1049. uint64_t *revocation_date
  1050. );
  1051. // key_created() - get creation date of a key
  1052. //
  1053. // parameters:
  1054. // session (in) session handle
  1055. // fpr (in) fingerprint of key
  1056. // created (out) date of creation
  1057. PEP_STATUS key_created(
  1058. PEP_SESSION session,
  1059. const char *fpr,
  1060. time_t *created
  1061. );
  1062. // find_private_keys() - find keys in keyring
  1063. //
  1064. // parameters:
  1065. // session (in) session handle
  1066. // pattern (in) key id, user id or address to search for as
  1067. // UTF-8 string
  1068. // keylist (out) list of fingerprints found or NULL on error
  1069. //
  1070. // caveat:
  1071. // the ownerships of keylist isgoing to the caller
  1072. // the caller must use free_stringlist() to free it
  1073. PEP_STATUS find_private_keys(PEP_SESSION session, const char* pattern,
  1074. stringlist_t **keylist);
  1075. // get_engine_version() - returns the current version of pEpEngine (this is different
  1076. // from the pEp protocol version!)
  1077. //
  1078. // parameters: none
  1079. //
  1080. // return_value: const char* to the engine version string constant
  1081. //
  1082. DYNAMIC_API const char* get_engine_version();
  1083. // get_protocol_version() - returns the pEp protocol version
  1084. DYNAMIC_API const char *get_protocol_version();
  1085. // is_pEp_user() - returns true if the USER corresponding to this identity
  1086. // has been listed in the *person* table as a pEp user.
  1087. //
  1088. // parameters:
  1089. // identity (in) - identity containing the user_id to check (this is
  1090. // the only part of the struct we require to be set)
  1091. // is_pEp (out) - boolean pointer - will return true or false by
  1092. // reference with respect to whether or not user is
  1093. // a known pEp user
  1094. //
  1095. // return_value: PEP_STATUS_OK if user found in person table
  1096. // PEP_ILLEGAL_VALUE if no user_id in input
  1097. // PEP_CANNOT_FIND_PERSON if user_id doesn't exist
  1098. //
  1099. // caveat: This *does not check comm_type*
  1100. //
  1101. DYNAMIC_API PEP_STATUS is_pEp_user(PEP_SESSION session,
  1102. pEp_identity *identity,
  1103. bool* is_pEp);
  1104. // per_user_directory() - returns the directory for pEp management db
  1105. //
  1106. // return_value:
  1107. // path to actual per user directory or NULL on failure
  1108. DYNAMIC_API const char *per_user_directory(void);
  1109. // per_machine_directory() - returns the directory for pEp system db
  1110. //
  1111. // return value:
  1112. // path to actual per user directory or NULL on failure
  1113. DYNAMIC_API const char *per_machine_directory(void);
  1114. PEP_STATUS _generate_keypair(PEP_SESSION session,
  1115. pEp_identity *identity,
  1116. bool suppress_event);
  1117. DYNAMIC_API PEP_STATUS reset_pEptest_hack(PEP_SESSION session);
  1118. // This is used internally when there is a temporary identity to be retrieved
  1119. // that may not yet have an FPR attached. See get_identity() for functionality,
  1120. // params and caveats.
  1121. PEP_STATUS get_identity_without_trust_check(
  1122. PEP_SESSION session,
  1123. const char *address,
  1124. const char *user_id,
  1125. pEp_identity **identity
  1126. );
  1127. PEP_STATUS get_identities_by_address(
  1128. PEP_SESSION session,
  1129. const char *address,
  1130. identity_list** id_list
  1131. );
  1132. PEP_STATUS get_identities_by_userid(
  1133. PEP_SESSION session,
  1134. const char *user_id,
  1135. identity_list **identities
  1136. );
  1137. PEP_STATUS is_own_address(PEP_SESSION session,
  1138. const char* address,
  1139. bool* is_own_addr);
  1140. PEP_STATUS replace_userid(PEP_SESSION session, const char* old_uid,
  1141. const char* new_uid);
  1142. PEP_STATUS remove_key(PEP_SESSION session, const char* fpr);
  1143. PEP_STATUS remove_fpr_as_default(PEP_SESSION session,
  1144. const char* fpr);
  1145. PEP_STATUS get_main_user_fpr(PEP_SESSION session,
  1146. const char* user_id,
  1147. char** main_fpr);
  1148. PEP_STATUS replace_main_user_fpr(PEP_SESSION session, const char* user_id,
  1149. const char* new_fpr);
  1150. PEP_STATUS replace_main_user_fpr_if_equal(PEP_SESSION session, const char* user_id,
  1151. const char* new_fpr, const char* compare_fpr);
  1152. DYNAMIC_API PEP_STATUS get_replacement_fpr(
  1153. PEP_SESSION session,
  1154. const char *fpr,
  1155. char **revoked_fpr,
  1156. uint64_t *revocation_date
  1157. );
  1158. PEP_STATUS refresh_userid_default_key(PEP_SESSION session, const char* user_id);
  1159. // This ONLY sets the *user* flag, and creates a shell identity if necessary.
  1160. DYNAMIC_API PEP_STATUS set_as_pEp_user(PEP_SESSION session, pEp_identity* user);
  1161. // returns true (by reference) if a person with this user_id exists;
  1162. // Also replaces aliased user_ids by defaults in identity.
  1163. PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity, bool* exists);
  1164. PEP_STATUS set_pgp_keypair(PEP_SESSION session, const char* fpr);
  1165. PEP_STATUS set_pEp_version(PEP_SESSION session, pEp_identity* ident, unsigned int new_ver_major, unsigned int new_ver_minor);
  1166. PEP_STATUS clear_trust_info(PEP_SESSION session,
  1167. const char* user_id,
  1168. const char* fpr);
  1169. // Generally ONLY called by set_as_pEp_user, and ONLY from < 2.0 to 2.0.
  1170. PEP_STATUS upgrade_pEp_version_by_user_id(PEP_SESSION session,
  1171. pEp_identity* ident,
  1172. unsigned int new_ver_major,
  1173. unsigned int new_ver_minor
  1174. );
  1175. // exposed for testing
  1176. PEP_STATUS set_person(PEP_SESSION session, pEp_identity* identity,
  1177. bool guard_transaction);
  1178. PEP_STATUS bind_own_ident_with_contact_ident(PEP_SESSION session,
  1179. pEp_identity* own_ident,
  1180. pEp_identity* contact_ident);
  1181. PEP_STATUS get_last_contacted(
  1182. PEP_SESSION session,
  1183. identity_list** id_list
  1184. );
  1185. PEP_STATUS get_own_ident_for_contact_id(PEP_SESSION session,
  1186. const pEp_identity* contact,
  1187. pEp_identity** own_ident);
  1188. PEP_STATUS exists_trust_entry(PEP_SESSION session, pEp_identity* identity,
  1189. bool* exists);
  1190. PEP_STATUS is_own_key(PEP_SESSION session, const char* fpr, bool* own_key);
  1191. PEP_STATUS get_identities_by_main_key_id(
  1192. PEP_SESSION session,
  1193. const char *fpr,
  1194. identity_list **identities);
  1195. PEP_STATUS sign_only(PEP_SESSION session,
  1196. const char *data,
  1197. size_t data_size,
  1198. const char *fpr,
  1199. char **sign,
  1200. size_t *sign_size);
  1201. PEP_STATUS set_all_userids_to_own(PEP_SESSION session,
  1202. identity_list* id_list);
  1203. PEP_STATUS has_partner_contacted_address(PEP_SESSION session, const char* partner_id,
  1204. const char* own_address, bool* was_contacted);
  1205. #ifdef __cplusplus
  1206. }
  1207. #endif