From 8a7fc79a3a9e2afc4f873437cfc16fc034a0a0b4 Mon Sep 17 00:00:00 2001 From: Krista 'DarthMama' Bennett Date: Tue, 8 Sep 2020 09:23:29 +0200 Subject: [PATCH] internal function comment stubs --- src/base64.c | 43 +++ src/etpan_mime.c | 272 +++++++++++++++ src/key_reset.c | 112 +++++++ src/keymanagement.c | 95 ++++++ src/message_api.c | 801 ++++++++++++++++++++++++++++++++++++++++++++ src/mime.c | 10 + src/pEpEngine.c | 229 +++++++++++++ src/pgp_sequoia.c | 342 +++++++++++++++++++ src/platform_unix.c | 43 +++ src/stringlist.c | 23 ++ 10 files changed, 1970 insertions(+) diff --git a/src/base64.c b/src/base64.c index 5b6d2f18..30135d18 100644 --- a/src/base64.c +++ b/src/base64.c @@ -28,6 +28,16 @@ static char translate_char_to_bits(char input) { return -1; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] in constchar + * + */ static bool _is_whitespace(const char in) { switch (in) { case ' ': @@ -40,6 +50,17 @@ static bool _is_whitespace(const char in) { } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *input constchar + * @param[in] length int + * + */ static size_t subtract_whitespace(const char* input, int length) { size_t actual_size = length; int i; @@ -51,6 +72,17 @@ static size_t subtract_whitespace(const char* input, int length) { return actual_size; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *input constchar + * @param[in] *length int + * + */ static void trim_end(const char* input, int* length) { const char* end = input + *length; @@ -65,6 +97,17 @@ static void trim_end(const char* input, int* length) { } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] **input_ptr constchar + * @param[in] *end constchar + * + */ char next_char(const char** input_ptr, const char* end) { const char* input = *input_ptr; char this_ch = 0; diff --git a/src/etpan_mime.c b/src/etpan_mime.c index 5bf8ea96..5ea43031 100644 --- a/src/etpan_mime.c +++ b/src/etpan_mime.c @@ -22,6 +22,15 @@ #define MAX_MESSAGE_ID 128 +/** + * @internal + * + * + * + * @brief TODO + * + * + */ static char * generate_boundary(void) { char id[MAX_MESSAGE_ID]; @@ -804,6 +813,18 @@ char * _get_filename_or_cid(struct mailmime *mime) return _temp_filename_ptr; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *content structmailmime_content + * @param[in] *name constchar + * @param[in] *value constchar + * + */ static bool parameter_has_value( struct mailmime_content *content, const char *name, @@ -880,6 +901,17 @@ bool _is_text_part(struct mailmime_content *content, const char *subtype) return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *content structmailmime_content + * @param[in] *subtype constchar + * + */ bool _is_message_part(struct mailmime_content *content, const char* subtype) { assert(content); if (content->ct_type && content->ct_type->tp_type == MAILMIME_TYPE_COMPOSITE_TYPE && @@ -1038,6 +1070,17 @@ static PEP_STATUS interpret_MIME(struct mailmime *mime, // temporary files when the pgp/mime support was implemented for // outlook, as the existing code did not work well on windows. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mime structmailmime + * @param[in] **mimetext char + * + */ static PEP_STATUS render_mime(struct mailmime *mime, char **mimetext) { PEP_STATUS status = PEP_STATUS_OK; @@ -1087,6 +1130,18 @@ pEp_error: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *blob bloblist_t + * @param[in] **result structmailmime + * @param[in] is_nf_message_attachment bool + * + */ static PEP_STATUS mime_attachment( bloblist_t *blob, struct mailmime **result, @@ -1144,6 +1199,19 @@ enomem: // "contained message" of pEp 2.x messages // on the initial encoding where it is turned // into attachment data!! +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *plaintext constchar + * @param[in] *htmltext constchar + * @param[in] *attachments bloblist_t + * @param[in] **result structmailmime + * + */ static PEP_STATUS mime_html_text( const char *plaintext, const char *htmltext, @@ -1324,6 +1392,16 @@ enomem: } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *ident constpEp_identity + * + */ static struct mailimf_mailbox * identity_to_mailbox(const pEp_identity *ident) { char *_username = NULL; @@ -1354,6 +1432,16 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *ident constpEp_identity + * + */ static struct mailimf_mailbox_list * identity_to_mbl( const pEp_identity *ident) { @@ -1392,6 +1480,16 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *il identity_list + * + */ static struct mailimf_address_list * identity_list_to_mal(identity_list *il) { struct mailimf_address_list *mal = NULL; @@ -1444,6 +1542,17 @@ enomem: // KB: This seems to be always called with "true", // but there was probably a reason for this. So // leave it for now. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *sl stringlist_t + * @param[in] transport_encode bool + * + */ static clist * stringlist_to_clist(stringlist_t *sl, bool transport_encode) { clist * cl = clist_new(); @@ -1477,6 +1586,17 @@ static clist * stringlist_to_clist(stringlist_t *sl, bool transport_encode) return cl; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg constmessage + * @param[in] **result structmailimf_fields + * + */ static PEP_STATUS build_fields(const message *msg, struct mailimf_fields **result) { PEP_STATUS status = PEP_STATUS_OK; @@ -1706,6 +1826,16 @@ enomem: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *filename char + * + */ static bool has_exceptional_extension(char* filename) { if (!filename) return false; @@ -1719,6 +1849,16 @@ static bool has_exceptional_extension(char* filename) { return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *rid_list pEp_rid_list_t + * + */ static pEp_rid_list_t* choose_resource_id(pEp_rid_list_t* rid_list) { pEp_rid_list_t* retval = rid_list; @@ -1768,6 +1908,19 @@ static pEp_rid_list_t* choose_resource_id(pEp_rid_list_t* rid_list) { // } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg constmessage + * @param[in] omit_fields bool + * @param[in] **result structmailmime + * @param[in] has_pEp_msg_attachment bool + * + */ static PEP_STATUS mime_encode_message_plain( const message *msg, bool omit_fields, @@ -1923,6 +2076,18 @@ pEp_error: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg constmessage + * @param[in] omit_fields bool + * @param[in] **result structmailmime + * + */ static PEP_STATUS mime_encode_message_PGP_MIME( const message * msg, bool omit_fields, @@ -2094,6 +2259,16 @@ pEp_error: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mb conststructmailimf_mailbox + * + */ static pEp_identity *mailbox_to_identity(const struct mailimf_mailbox * mb) { char *username = NULL; @@ -2141,12 +2316,32 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mbl conststructmailimf_mailbox_list + * + */ static pEp_identity * mbl_to_identity(const struct mailimf_mailbox_list * mbl) { struct mailimf_mailbox * mb = clist_content(clist_begin(mbl->mb_list)); return mailbox_to_identity(mb); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mal conststructmailimf_address_list + * + */ static identity_list * mal_to_identity_list( const struct mailimf_address_list *mal ) @@ -2205,6 +2400,16 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *list constclist + * + */ static stringlist_t * clist_to_stringlist(const clist *list) { char *text = NULL;; @@ -2239,6 +2444,17 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * @param[in] *fieldlist clist + * + */ static PEP_STATUS read_fields(message *msg, clist *fieldlist) { PEP_STATUS status = PEP_STATUS_OK; @@ -2449,6 +2665,18 @@ pEp_error: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *part structmailmime + * @param[in] **longmsg char + * @param[in] *size size_t + * + */ static PEP_STATUS interpret_body(struct mailmime *part, char **longmsg, size_t *size) { const char *text; @@ -2526,6 +2754,17 @@ static PEP_STATUS interpret_body(struct mailmime *part, char **longmsg, size_t * // THIS IS A BEST-EFFORT ONLY FUNCTION, AND WE ARE NOT DOING MORE THAN THE // SUBJECT FOR NOW. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mime structmailmime + * @param[in] *msg message + * + */ static PEP_STATUS interpret_protected_headers( struct mailmime* mime, message* msg @@ -2566,6 +2805,17 @@ static PEP_STATUS interpret_protected_headers( } // ONLY for main part!!! +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mime structmailmime + * @param[in] *msg message + * + */ static PEP_STATUS process_multipart_related(struct mailmime *mime, message *msg) { PEP_STATUS status = PEP_STATUS_OK; @@ -2622,6 +2872,16 @@ static PEP_STATUS process_multipart_related(struct mailmime *mime, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *fields structmailmime_fields + * + */ static bool _is_marked_as_attachment(struct mailmime_fields *fields) { if (!(fields && fields->fld_list)) @@ -2642,6 +2902,18 @@ static bool _is_marked_as_attachment(struct mailmime_fields *fields) return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *mime structmailmime + * @param[in] *msg message + * @param[in] *has_possible_pEp_msg bool + * + */ static PEP_STATUS interpret_MIME( struct mailmime *mime, message *msg, diff --git a/src/key_reset.c b/src/key_reset.c index 3df6a683..47494309 100644 --- a/src/key_reset.c +++ b/src/key_reset.c @@ -23,11 +23,37 @@ #define KEY_RESET_MAJOR_VERSION 1L #define KEY_RESET_MINOR_VERSION 0L +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * + */ static void _add_auto_consume(message* msg) { add_opt_field(msg, "pEp-auto-consume", "yes"); msg->in_reply_to = stringlist_add(msg->in_reply_to, "pEp-auto-consume@pEp.foundation"); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *reset_ident constpEp_identity + * @param[in] *old_fpr constchar + * @param[in] *new_fpr constchar + * @param[in] **key_attachments bloblist_t + * @param[in] **command_list keyreset_command_list + * @param[in] include_secret bool + * + */ static PEP_STATUS _generate_reset_structs(PEP_SESSION session, const pEp_identity* reset_ident, const char* old_fpr, @@ -134,6 +160,19 @@ pEp_error: // For multiple idents under a single key // idents contain new fprs +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *from_idents identity_list + * @param[in] *old_fpr constchar + * @param[in] **dst message + * + */ static PEP_STATUS _generate_own_commandlist_msg(PEP_SESSION session, identity_list* from_idents, const char* old_fpr, @@ -218,6 +257,22 @@ pEp_error: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *from_ident constpEp_identity + * @param[in] *to_ident constpEp_identity + * @param[in] *old_fpr constchar + * @param[in] *new_fpr constchar + * @param[in] is_private bool + * @param[in] **dst message + * + */ static PEP_STATUS _generate_keyreset_command_message(PEP_SESSION session, const pEp_identity* from_ident, const pEp_identity* to_ident, @@ -942,6 +997,17 @@ DYNAMIC_API PEP_STATUS key_reset_all_own_keys(PEP_SESSION session) { return key_reset(session, NULL, NULL); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *idents identity_list + * @param[in] **filtered identity_list + * + */ static PEP_STATUS _dup_grouped_only(identity_list* idents, identity_list** filtered) { if (!idents) return PEP_STATUS_OK; @@ -975,6 +1041,17 @@ static PEP_STATUS _dup_grouped_only(identity_list* idents, identity_list** filte return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *key constchar + * + */ static PEP_STATUS _check_own_reset_passphrase_readiness(PEP_SESSION session, const char* key) { @@ -1036,6 +1113,19 @@ static PEP_STATUS _check_own_reset_passphrase_readiness(PEP_SESSION session, // FIXME: // I am not sure this is safe with already-revoked keys. // +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *key_idents identity_list + * @param[in] *old_key constchar + * @param[in] grouped_only bool + * + */ static PEP_STATUS _key_reset_device_group_for_shared_key(PEP_SESSION session, identity_list* key_idents, const char* old_key, @@ -1566,6 +1656,17 @@ pEp_free: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *command_list constkeyreset_command_list + * @param[in] *dist Distribution_t + * + */ Distribution_t *Distribution_from_keyreset_command_list( const keyreset_command_list *command_list, Distribution_t *dist @@ -1671,6 +1772,17 @@ the_end: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *dist Distribution_t + * @param[in] *command_list keyreset_command_list + * + */ keyreset_command_list * Distribution_to_keyreset_command_list( Distribution_t *dist, keyreset_command_list *command_list diff --git a/src/keymanagement.c b/src/keymanagement.c index 67592dc6..bd2f479f 100644 --- a/src/keymanagement.c +++ b/src/keymanagement.c @@ -44,6 +44,18 @@ static bool key_matches_address(PEP_SESSION session, const char* address, } // Does not return PASSPHRASE errors +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * @param[in] check_blacklist bool + * + */ PEP_STATUS elect_pubkey( PEP_SESSION session, pEp_identity * identity, bool check_blacklist ) @@ -113,6 +125,20 @@ PEP_STATUS elect_pubkey( // possibly having an own pubkey that we need to check on its own // N.B. Checked for PASSPHRASE errors - will now return them always // False value of "renew_private" prevents their possibility, though. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *ident pEp_identity + * @param[in] check_blacklist bool + * @param[in] own_must_contain_private bool + * @param[in] renew_private bool + * + */ static PEP_STATUS validate_fpr(PEP_SESSION session, pEp_identity* ident, bool check_blacklist, @@ -477,6 +503,17 @@ PEP_STATUS get_valid_pubkey(PEP_SESSION session, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *new_ident pEp_identity + * @param[in] *stored_ident pEp_identity + * + */ static void transfer_ident_lang_and_flags(pEp_identity* new_ident, pEp_identity* stored_ident) { if (new_ident->lang[0] == 0) { @@ -489,6 +526,17 @@ static void transfer_ident_lang_and_flags(pEp_identity* new_ident, new_ident->me = new_ident->me || stored_ident->me; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * + */ static void adjust_pEp_trust_status(PEP_SESSION session, pEp_identity* identity) { assert(session); assert(identity); @@ -517,6 +565,19 @@ static void adjust_pEp_trust_status(PEP_SESSION session, pEp_identity* identity) // and friends NEVER return with a password error. // (get_valid_pubkey tells validate_fpr not to try renewal) // Will not return PASSPHRASE errors. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *return_id pEp_identity + * @param[in] *stored_ident pEp_identity + * @param[in] store bool + * + */ static PEP_STATUS prepare_updated_identity(PEP_SESSION session, pEp_identity* return_id, pEp_identity* stored_ident, @@ -1028,6 +1089,17 @@ pEp_free: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * + */ PEP_STATUS elect_ownkey( PEP_SESSION session, pEp_identity * identity ) @@ -1098,6 +1170,18 @@ PEP_STATUS elect_ownkey( return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *fpr char + * @param[in] *is_usable bool + * + */ PEP_STATUS _has_usable_priv_key(PEP_SESSION session, char* fpr, bool* is_usable) { @@ -2119,6 +2203,17 @@ PEP_STATUS is_mistrusted_key(PEP_SESSION session, const char* fpr, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *ident pEp_identity + * + */ static PEP_STATUS _wipe_default_key_if_invalid(PEP_SESSION session, pEp_identity* ident) { diff --git a/src/message_api.c b/src/message_api.c index 4e4eff4b..cd34b6b2 100644 --- a/src/message_api.c +++ b/src/message_api.c @@ -30,6 +30,16 @@ int _pEp_rand_max_bits; double _pEp_log2_36; +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg constmessage + * + */ static bool is_a_pEpmessage(const message *msg) { for (stringpair_list_t *i = msg->opt_fields; i && i->value ; i=i->next) { @@ -39,6 +49,16 @@ static bool is_a_pEpmessage(const message *msg) return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *keylist conststringlist_t + * + */ static char * keylist_to_string(const stringlist_t *keylist) { if (keylist) { @@ -67,6 +87,16 @@ static char * keylist_to_string(const stringlist_t *keylist) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] rating PEP_rating + * + */ static const char * rating_to_string(PEP_rating rating) { switch (rating) { @@ -97,6 +127,19 @@ static const char * rating_to_string(PEP_rating rating) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *needle constchar + * @param[in] needle_size size_t + * @param[in] *haystack constchar + * @param[in] haystack_size size_t + * + */ bool _memnmemn(const char* needle, size_t needle_size, const char* haystack, @@ -155,6 +198,19 @@ void add_opt_field(message *msg, const char *name, const char *value) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * @param[in] *name constchar + * @param[in] *value constchar + * @param[in] clobber bool + * + */ void replace_opt_field(message *msg, const char *name, const char *value, @@ -212,6 +268,16 @@ void decorate_message( } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *uri char + * + */ static char* _get_resource_ptr_noown(char* uri) { char* uri_delim = strstr(uri, "://"); if (!uri_delim) @@ -230,6 +296,17 @@ static bool string_equality(const char *s1, const char *s2) return strcmp(s1, s2) == 0; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *bl constbloblist_t + * @param[in] *mt constchar + * + */ static bool is_mime_type(const bloblist_t *bl, const char *mt) { assert(mt); @@ -243,6 +320,17 @@ static bool is_mime_type(const bloblist_t *bl, const char *mt) // return true, but if bl->filename is ".pgp" and fe is ".pgp", it will // return false. This is desired behaviour. // +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *bl constbloblist_t + * @param[in] *fe constchar + * + */ static bool is_fileending(const bloblist_t *bl, const char *fe) { assert(fe); @@ -263,6 +351,17 @@ static bool is_fileending(const bloblist_t *bl, const char *fe) return strcmp(bl->filename + (fn_len - fe_len), fe) == 0; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg_wrap_info constchar + * @param[in] *longmsg constchar + * + */ char * encapsulate_message_wrap_info(const char *msg_wrap_info, const char *longmsg) { assert(msg_wrap_info); @@ -297,6 +396,17 @@ char * encapsulate_message_wrap_info(const char *msg_wrap_info, const char *long return ptext; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *shortmsg constchar + * @param[in] *longmsg constchar + * + */ static char * combine_short_and_long(const char *shortmsg, const char *longmsg) { assert(shortmsg); @@ -346,6 +456,16 @@ static char * combine_short_and_long(const char *shortmsg, const char *longmsg) return ptext; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * + */ static PEP_STATUS replace_subject(message* msg) { unsigned char pEpstr[] = PEP_SUBJ_STRING; if (msg->shortmsg && *(msg->shortmsg) != '\0') { @@ -370,6 +490,16 @@ static PEP_STATUS replace_subject(message* msg) { return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] num_bits int + * + */ unsigned long long get_bitmask(int num_bits) { if (num_bits <= 0) return 0; @@ -408,6 +538,15 @@ static char* get_base_36_rep(unsigned long long value, int num_sig_bits) { } +/** + * @internal + * + * + * + * @brief TODO + * + * + */ static char* message_id_prand_part(void) { // RAND modulus int num_bits = _pEp_rand_max_bits; @@ -445,6 +584,16 @@ static char* message_id_prand_part(void) { return get_base_36_rep(output_value, DESIRED_BITS); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * + */ static PEP_STATUS generate_message_id(message* msg) { if (!msg || !msg->from || !msg->from->address) @@ -533,6 +682,20 @@ enomem: Does case-insensitive compare of keys, so sending in a lower-cased string constant saves a bit of computation */ +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *plaintext constchar + * @param[in] *key constchar + * @param[in] keylen constsize_t + * @param[in] **data char + * @param[in] **modified_msg char + * + */ static PEP_STATUS get_data_from_encapsulated_line(const char* plaintext, const char* key, const size_t keylen, char** data, char** modified_msg) { @@ -576,6 +739,19 @@ static PEP_STATUS get_data_from_encapsulated_line(const char* plaintext, const c } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src constchar + * @param[in] **shortmsg char + * @param[in] **msg_wrap_info char + * @param[in] **longmsg char + * + */ static int separate_short_and_long(const char *src, char **shortmsg, char** msg_wrap_info, char **longmsg) { char *_shortmsg = NULL; @@ -643,6 +819,17 @@ enomem: return -1; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *dst message + * @param[in] *src constmessage + * + */ static PEP_STATUS copy_fields(message *dst, const message *src) { assert(dst); @@ -760,6 +947,17 @@ static PEP_STATUS copy_fields(message *dst, const message *src) } // FIXME: error mem leakage +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src constmessage + * @param[in] direct PEP_msg_direction + * + */ static message* extract_minimal_envelope(const message* src, PEP_msg_direction direct) { @@ -824,6 +1022,16 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src constmessage + * + */ static message * clone_to_empty_message(const message * src) { PEP_STATUS status; @@ -851,6 +1059,22 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *envelope message + * @param[in] *attachment message + * @param[in] wrap_type message_wrap_type + * @param[in] keep_orig_subject bool + * @param[in] *extra_keys stringlist_t + * @param[in] max_major unsignedint + * @param[in] max_minor unsignedint + * + */ static message* wrap_message_as_attachment(message* envelope, message* attachment, message_wrap_type wrap_type, bool keep_orig_subject, stringlist_t* extra_keys, @@ -959,6 +1183,20 @@ enomem: return NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *src constmessage + * @param[in] *keys stringlist_t + * @param[in] *dst message + * @param[in] flags PEP_encrypt_flags_t + * + */ static PEP_STATUS encrypt_PGP_inline( PEP_SESSION session, const message *src, @@ -1080,6 +1318,21 @@ static PEP_STATUS encrypt_PGP_inline( return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *src constmessage + * @param[in] *keys stringlist_t + * @param[in] *dst message + * @param[in] flags PEP_encrypt_flags_t + * @param[in] wrap_type message_wrap_type + * + */ static PEP_STATUS encrypt_PGP_MIME( PEP_SESSION session, const message *src, @@ -1188,6 +1441,16 @@ static bool _has_PGP_MIME_format(message* msg) { } */ +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] ct PEP_comm_type + * + */ static inline PEP_rating _rating(PEP_comm_type ct) { if (ct == PEP_ct_unknown) @@ -1224,6 +1487,16 @@ DYNAMIC_API PEP_rating rating_from_comm_type(PEP_comm_type ct) return _rating(ct); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *blob constbloblist_t + * + */ static bool is_encrypted_attachment(const bloblist_t *blob) { assert(blob); @@ -1253,6 +1526,16 @@ static bool is_encrypted_attachment(const bloblist_t *blob) return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *blob constbloblist_t + * + */ static bool is_encrypted_html_attachment(const bloblist_t *blob) { assert(blob); @@ -1271,6 +1554,16 @@ static bool is_encrypted_html_attachment(const bloblist_t *blob) return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *filename constchar + * + */ static char * without_double_ending(const char *filename) { assert(filename); @@ -1286,6 +1579,16 @@ static char * without_double_ending(const char *filename) return result; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] status PEP_STATUS + * + */ static PEP_rating decrypt_rating(PEP_STATUS status) { switch (status) { @@ -1315,6 +1618,17 @@ static PEP_rating decrypt_rating(PEP_STATUS status) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *fpr constchar + * + */ static PEP_rating key_rating(PEP_SESSION session, const char *fpr) { @@ -1352,6 +1666,19 @@ static PEP_rating worst_rating(PEP_rating rating1, PEP_rating rating2) { return ((rating1 < rating2) ? rating1 : rating2); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *keylist stringlist_t + * @param[in] *sender_fpr char + * @param[in] sender_rating PEP_rating + * + */ static PEP_rating keylist_rating(PEP_SESSION session, stringlist_t *keylist, char* sender_fpr, PEP_rating sender_rating) { PEP_rating rating = sender_rating; @@ -1385,6 +1712,18 @@ static PEP_rating keylist_rating(PEP_SESSION session, stringlist_t *keylist, cha // We do not want myself() setting the fpr here. // // Cannot return passphrase statuses. No keygen or renewal allowed here. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] max_comm_type PEP_comm_type + * @param[in] *ident pEp_identity + * + */ static PEP_comm_type _get_comm_type( PEP_SESSION session, PEP_comm_type max_comm_type, @@ -1422,6 +1761,18 @@ static PEP_comm_type _get_comm_type( } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] max_comm_type PEP_comm_type + * @param[in] *ident pEp_identity + * + */ static PEP_comm_type _get_comm_type_preview( PEP_SESSION session, PEP_comm_type max_comm_type, @@ -1471,6 +1822,16 @@ static PEP_comm_type _get_comm_type_preview( // } // } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *bl constbloblist_t + * + */ static bool is_key(const bloblist_t *bl) { return (// workaround for Apple Mail bugs @@ -1514,6 +1875,18 @@ static bool is_key(const bloblist_t *bl) // } // } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *first constchar + * @param[in] *second constchar + * @param[in] n size_t + * + */ static bool compare_first_n_bytes(const char* first, const char* second, size_t n) { size_t i; for (i = 0; i < n; i++) { @@ -1649,6 +2022,18 @@ bool import_attached_keys( } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *fpr constchar + * @param[in] *msg message + * + */ PEP_STATUS _attach_key(PEP_SESSION session, const char* fpr, message *msg) { char *keydata = NULL; @@ -1732,6 +2117,17 @@ PEP_cryptotech determine_encryption_format(message *msg) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * @param[in] remove_attached_key bool + * + */ static void _cleanup_src(message* src, bool remove_attached_key) { assert(src); @@ -1763,6 +2159,18 @@ static void _cleanup_src(message* src, bool remove_attached_key) { } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *id_list identity_list + * @param[in] enc_format PEP_enc_format + * + */ static PEP_STATUS id_list_set_enc_format(PEP_SESSION session, identity_list* id_list, PEP_enc_format enc_format) { PEP_STATUS status = PEP_STATUS_OK; identity_list* id_list_curr = id_list; @@ -1774,6 +2182,17 @@ static PEP_STATUS id_list_set_enc_format(PEP_SESSION session, identity_list* id_ // N.B. // depends on update_identity and friends having already been called on list +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *id_list identity_list + * @param[in] *enc_format PEP_enc_format + * + */ static void update_encryption_format(identity_list* id_list, PEP_enc_format* enc_format) { identity_list* id_list_curr; for (id_list_curr = id_list; id_list_curr && id_list_curr->ident; id_list_curr = id_list_curr->next) { @@ -1803,6 +2222,16 @@ DYNAMIC_API PEP_STATUS probe_encrypt(PEP_SESSION session, const char *fpr) return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] status PEP_STATUS + * + */ static bool failed_test(PEP_STATUS status) { if (status == PEP_OUT_OF_MEMORY || @@ -1815,6 +2244,25 @@ static bool failed_test(PEP_STATUS status) } // CANNOT return PASSPHRASE errors, as no gen or renew allowed below +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *from_ident pEp_identity + * @param[in] *ident_list identity_list + * @param[in] **keylist stringlist_t + * @param[in] *max_comm_type PEP_comm_type + * @param[in] *max_version_major unsignedint + * @param[in] *max_version_minor unsignedint + * @param[in] *has_pEp_user bool + * @param[in] *dest_keys_found bool + * @param[in] suppress_update_for_bcc bool + * + */ static PEP_STATUS _update_state_for_ident_list( PEP_SESSION session, pEp_identity* from_ident, @@ -2599,6 +3047,17 @@ pEp_error: // } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *msg message + * @param[in] **signature_blob bloblist_t + * + */ static PEP_STATUS _get_detached_signature(message* msg, bloblist_t** signature_blob) { bloblist_t* attach_curr = msg->attachments; @@ -2617,6 +3076,19 @@ static PEP_STATUS _get_detached_signature(message* msg, return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *ptext constchar + * @param[in] psize constsize_t + * @param[in] **stext char + * @param[in] *ssize size_t + * + */ static PEP_STATUS _get_signed_text(const char* ptext, const size_t psize, char** stext, size_t* ssize) { @@ -2692,6 +3164,19 @@ static PEP_STATUS _get_signed_text(const char* ptext, const size_t psize, return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] **verify_in stringlist_t + * @param[in] **keylist_in_out stringlist_t + * @param[in] *from pEp_identity + * + */ static PEP_STATUS combine_keylists(PEP_SESSION session, stringlist_t** verify_in, stringlist_t** keylist_in_out, pEp_identity* from) { @@ -2771,6 +3256,19 @@ free: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *rating PEP_rating + * @param[in] *sender pEp_identity + * @param[in] *recipients stringlist_t + * + */ static PEP_STATUS amend_rating_according_to_sender_and_recipients( PEP_SESSION session, PEP_rating *rating, @@ -2815,6 +3313,16 @@ static PEP_STATUS amend_rating_according_to_sender_and_recipients( } // FIXME: Do we need to remove the attachment? I think we do... +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * + */ static bool pull_up_attached_main_msg(message* src) { char* slong = src->longmsg; char* sform = src->longmsg_formatted; @@ -2849,6 +3357,18 @@ static bool pull_up_attached_main_msg(message* src) { +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * @param[in] *msg message + * @param[in] **msg_wrap_info char + * + */ static PEP_STATUS unencapsulate_hidden_fields(message* src, message* msg, char** msg_wrap_info) { if (!src) @@ -2941,6 +3461,18 @@ static PEP_STATUS unencapsulate_hidden_fields(message* src, message* msg, } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * @param[in] **crypto_text char + * @param[in] *text_size size_t + * + */ static PEP_STATUS get_crypto_text(message* src, char** crypto_text, size_t* text_size) { // this is only here because of how NOT_IMPLEMENTED works @@ -2989,6 +3521,23 @@ static PEP_STATUS get_crypto_text(message* src, char** crypto_text, size_t* text } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *src message + * @param[in] *msg message + * @param[in] *plaintext char + * @param[in] plaintext_size size_t + * @param[in] **keylist stringlist_t + * @param[in] *decrypt_status PEP_STATUS + * @param[in] crypto PEP_cryptotech + * + */ static PEP_STATUS verify_decrypted(PEP_SESSION session, message* src, message* msg, @@ -3056,6 +3605,20 @@ static PEP_STATUS verify_decrypted(PEP_SESSION session, return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *src message + * @param[in] **msg_ptr message + * @param[in] *ptext char + * @param[in] psize size_t + * + */ static PEP_STATUS _decrypt_in_pieces(PEP_SESSION session, message* src, message** msg_ptr, @@ -3268,6 +3831,19 @@ static PEP_STATUS import_keys_from_decrypted_msg(PEP_SESSION session, } // ident is in_only and should have been updated +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *ident pEp_identity + * @param[in] major unsignedint + * @param[in] minor unsignedint + * + */ static PEP_STATUS pEp_version_upgrade_or_ignore( PEP_SESSION session, pEp_identity* ident, @@ -3283,6 +3859,20 @@ static PEP_STATUS pEp_version_upgrade_or_ignore( } // FIXME: myself ?????? +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *sender pEp_identity + * @param[in] *keylist stringlist_t + * @param[in] major unsignedint + * @param[in] minor unsignedint + * + */ static PEP_STATUS update_sender_to_pEp_trust( PEP_SESSION session, pEp_identity* sender, @@ -3352,6 +3942,17 @@ static PEP_STATUS update_sender_to_pEp_trust( return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *srcid pEp_identity + * @param[in] *resultid pEp_identity + * + */ static PEP_STATUS reconcile_identity(pEp_identity* srcid, pEp_identity* resultid) { assert(srcid); @@ -3377,6 +3978,17 @@ static PEP_STATUS reconcile_identity(pEp_identity* srcid, return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src_ids identity_list + * @param[in] *result_ids identity_list + * + */ static PEP_STATUS reconcile_identity_lists(identity_list* src_ids, identity_list* result_ids) { @@ -3406,6 +4018,17 @@ static PEP_STATUS reconcile_identity_lists(identity_list* src_ids, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * @param[in] *inner_message message + * + */ static PEP_STATUS reconcile_sent_and_recv_info(message* src, message* inner_message) { if (!src || !inner_message) return PEP_ILLEGAL_VALUE; @@ -3419,6 +4042,17 @@ static PEP_STATUS reconcile_sent_and_recv_info(message* src, message* inner_mess return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *src message + * @param[in] *inner_message message + * + */ static PEP_STATUS reconcile_src_and_inner_messages(message* src, message* inner_message) { @@ -3446,6 +4080,18 @@ static PEP_STATUS reconcile_src_and_inner_messages(message* src, // FIXME - are there any flags or anything else we need to be sure are carried? } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *own_id constchar + * @param[in] *fpr constchar + * + */ static bool is_trusted_own_priv_fpr(PEP_SESSION session, const char* own_id, const char* fpr @@ -3470,6 +4116,17 @@ static bool is_trusted_own_priv_fpr(PEP_SESSION session, return retval; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *fpr constchar + * + */ static bool reject_fpr(PEP_SESSION session, const char* fpr) { bool reject = true; @@ -3488,6 +4145,18 @@ static bool reject_fpr(PEP_SESSION session, const char* fpr) { return reject; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *own_id char + * @param[in] *keylist stringlist_t + * + */ static char* seek_good_trusted_private_fpr(PEP_SESSION session, char* own_id, stringlist_t* keylist) { if (!own_id || !keylist) @@ -3551,6 +4220,18 @@ static bool import_header_keys(PEP_SESSION session, message* src, stringlist_t** return false; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *keylist stringlist_t + * @param[in] **revoked_fpr_pairs stringpair_list_t + * + */ PEP_STATUS check_for_own_revoked_key( PEP_SESSION session, stringlist_t* keylist, @@ -3617,6 +4298,16 @@ pEp_free: } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *keylist stringlist_t + * + */ static bool _have_extrakeys(stringlist_t *keylist) { return keylist @@ -3627,6 +4318,18 @@ static bool _have_extrakeys(stringlist_t *keylist) // practically speaking, only useful to get user_id/address intersection // we presume no dups in the first list if you're looking for // a unique result. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *list_a identity_list + * @param[in] *list_b identity_list + * @param[in] **intersection identity_list + * + */ static PEP_STATUS ident_list_intersect(identity_list* list_a, identity_list* list_b, identity_list** intersection) { @@ -4687,6 +5390,19 @@ DYNAMIC_API PEP_STATUS own_message_private_key_details( // we were unable to get key information for anyone in the list, // likely because a key is missing. // Cannot propagate PASSPHRASE errors. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *identities identity_list + * @param[in] session PEP_SESSION + * @param[in] *max_comm_type PEP_comm_type + * @param[in] *comm_type_determined bool + * + */ static void _max_comm_type_from_identity_list( identity_list *identities, PEP_SESSION session, @@ -4737,6 +5453,18 @@ static void _max_comm_type_from_identity_list( } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *identities identity_list + * @param[in] session PEP_SESSION + * @param[in] *max_comm_type PEP_comm_type + * + */ static void _max_comm_type_from_identity_list_preview( identity_list *identities, PEP_SESSION session, @@ -4927,6 +5655,16 @@ DYNAMIC_API PEP_color color_from_rating(PEP_rating rating) } /* [0-9]: 0x30 - 0x39; [A-F] = 0x41 - 0x46; [a-f] = 0x61 - 0x66 */ +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] a char + * + */ static short asciihex_to_num(char a) { short conv_num = -1; if (a >= 0x30 && a <= 0x39) @@ -4940,6 +5678,16 @@ static short asciihex_to_num(char a) { return conv_num; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] h short + * + */ static char num_to_asciihex(short h) { if (h < 0 || h > 16) return '\0'; @@ -4948,6 +5696,17 @@ static char num_to_asciihex(short h) { return (char)((h - 10) + 0x41); // for readability } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] a char + * @param[in] b char + * + */ static char xor_hex_chars(char a, char b) { short a_num = asciihex_to_num(a); short b_num = asciihex_to_num(b); @@ -4957,6 +5716,17 @@ static char xor_hex_chars(char a, char b) { return num_to_asciihex(xor_num); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *current constchar + * @param[in] *begin constchar + * + */ static const char* skip_separators(const char* current, const char* begin) { while (current >= begin) { /* .:,;-_ ' ' - [2c-2e] [3a-3b] [20] [5f] */ @@ -4979,6 +5749,16 @@ static const char* skip_separators(const char* current, const char* begin) { return current; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *fpr char + * + */ PEP_STATUS check_for_zero_fpr(char* fpr) { PEP_STATUS status = PEP_TRUSTWORDS_DUPLICATE_FPR; @@ -5261,6 +6041,16 @@ DYNAMIC_API PEP_STATUS get_message_trustwords( return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *rating constchar + * + */ static PEP_rating string_to_rating(const char * rating) { if (rating == NULL) @@ -5292,6 +6082,17 @@ static PEP_rating string_to_rating(const char * rating) return PEP_rating_undefined; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *skeylist constchar + * @param[in] **keylist stringlist_t + * + */ static PEP_STATUS string_to_keylist(const char * skeylist, stringlist_t **keylist) { if (skeylist == NULL || keylist == NULL) diff --git a/src/mime.c b/src/mime.c index 7c4b04dc..2fd25c31 100644 --- a/src/mime.c +++ b/src/mime.c @@ -12,6 +12,16 @@ #include #include +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] c char + * + */ static bool is_whitespace(char c) { switch (c) { diff --git a/src/pEpEngine.c b/src/pEpEngine.c index e6b77d29..9e367c8d 100644 --- a/src/pEpEngine.c +++ b/src/pEpEngine.c @@ -539,6 +539,19 @@ static const char *sql_has_id_contacted_address = static const char *sql_get_last_contacted = "select user_id, address from identity where datetime('now') < datetime(timestamp, '+14 days') ; "; +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *_version void + * @param[in] count int + * @param[in] **text char + * @param[in] **name char + * + */ static int user_version(void *_version, int count, char **text, char **name) { if (!(_version && count == 1 && text && text[0])) @@ -550,6 +563,17 @@ static int user_version(void *_version, int count, char **text, char **name) } // TODO: refactor and generalise these two functions if possible. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *table_name constchar + * + */ static int db_contains_table(PEP_SESSION session, const char* table_name) { if (!session || !table_name) return -1; @@ -594,6 +618,18 @@ static int db_contains_table(PEP_SESSION session, const char* table_name) { } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *table_name constchar + * @param[in] *col_name constchar + * + */ static int table_contains_column(PEP_SESSION session, const char* table_name, const char* col_name) { @@ -644,6 +680,16 @@ static int table_contains_column(PEP_SESSION session, const char* table_name, return retval; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * + */ PEP_STATUS repair_altered_tables(PEP_SESSION session) { PEP_STATUS status = PEP_STATUS_OK; @@ -822,6 +868,18 @@ pEp_free: free(table_names); return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *pArg void + * @param[in] iErrCode int + * @param[in] *zMsg constchar + * + */ void errorLogCallback(void *pArg, int iErrCode, const char *zMsg){ fprintf(stderr, "(%d) %s\n", iErrCode, zMsg); } @@ -3108,6 +3166,18 @@ PEP_STATUS get_identities_by_address( return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * @param[in] *exists bool + * + */ PEP_STATUS exists_identity_entry(PEP_SESSION session, pEp_identity* identity, bool* exists) { if (!session || !exists || !identity || EMPTYSTR(identity->user_id) || EMPTYSTR(identity->address)) @@ -3323,6 +3393,18 @@ PEP_STATUS set_or_update_with_identity(PEP_SESSION session, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * @param[in] guard_transaction bool + * + */ PEP_STATUS _set_trust_internal(PEP_SESSION session, pEp_identity* identity, bool guard_transaction) { return set_or_update_with_identity(session, identity, @@ -3356,6 +3438,18 @@ PEP_STATUS set_person(PEP_SESSION session, pEp_identity* identity, guard_transaction); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * @param[in] guard_transaction bool + * + */ PEP_STATUS set_identity_entry(PEP_SESSION session, pEp_identity* identity, bool guard_transaction) { return set_or_update_with_identity(session, identity, @@ -3444,6 +3538,17 @@ pEp_free: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *user pEp_identity + * + */ PEP_STATUS update_pEp_user_trust_vals(PEP_SESSION session, pEp_identity* user) { if (!user->user_id) @@ -3588,6 +3693,17 @@ PEP_STATUS exists_person(PEP_SESSION session, pEp_identity* identity, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *user_id constchar + * + */ PEP_STATUS delete_person(PEP_SESSION session, const char* user_id) { if (!session || EMPTYSTR(user_id)) @@ -3939,6 +4055,18 @@ DYNAMIC_API PEP_STATUS set_ident_enc_format( return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *user_id constchar + * @param[in] **trust_list labeled_int_list_t + * + */ PEP_STATUS get_trust_by_userid(PEP_SESSION session, const char* user_id, labeled_int_list_t** trust_list) { @@ -3969,6 +4097,17 @@ PEP_STATUS get_trust_by_userid(PEP_SESSION session, const char* user_id, return PEP_STATUS_OK; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] t_old PEP_comm_type + * @param[in] t_new PEP_comm_type + * + */ PEP_comm_type reconcile_trust(PEP_comm_type t_old, PEP_comm_type t_new) { switch (t_new) { case PEP_ct_mistrusted: @@ -3998,6 +4137,18 @@ PEP_comm_type reconcile_trust(PEP_comm_type t_old, PEP_comm_type t_new) { return result; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *old_uid constchar + * @param[in] *new_uid constchar + * + */ PEP_STATUS reconcile_pEp_status(PEP_SESSION session, const char* old_uid, const char* new_uid) { PEP_STATUS status = PEP_STATUS_OK; @@ -4020,6 +4171,18 @@ pEp_free: return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *old_name constchar + * @param[in] *new_name constchar + * @param[in] *address constchar + * + */ const char* reconcile_usernames(const char* old_name, const char* new_name, const char* address) { if (EMPTYSTR(old_name)) { @@ -4035,6 +4198,18 @@ const char* reconcile_usernames(const char* old_name, const char* new_name, return new_name; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *old_ident pEp_identity + * @param[in] *new_ident pEp_identity + * + */ PEP_STATUS reconcile_default_keys(PEP_SESSION session, pEp_identity* old_ident, pEp_identity* new_ident) { PEP_STATUS status = PEP_STATUS_OK; @@ -4087,6 +4262,17 @@ PEP_STATUS reconcile_default_keys(PEP_SESSION session, pEp_identity* old_ident, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *old_ident pEp_identity + * @param[in] *new_ident pEp_identity + * + */ void reconcile_language(pEp_identity* old_ident, pEp_identity* new_ident) { if (new_ident->lang[0] == 0) { @@ -4099,6 +4285,18 @@ void reconcile_language(pEp_identity* old_ident, } // ONLY CALL THIS IF BOTH IDs ARE IN THE PERSON DB, FOOL! +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *old_uid constchar + * @param[in] *new_uid constchar + * + */ PEP_STATUS merge_records(PEP_SESSION session, const char* old_uid, const char* new_uid) { PEP_STATUS status = PEP_STATUS_OK; @@ -4525,6 +4723,16 @@ DYNAMIC_API PEP_STATUS least_trust( return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *filename char + * + */ static void sanitize_pgp_filename(char *filename) { for (int i=0; filename[i]; ++i) { @@ -4872,6 +5080,16 @@ DYNAMIC_API PEP_STATUS config_cipher_suite(PEP_SESSION session, return session->cryptotech[PEP_crypt_OpenPGP].config_cipher_suite(session, suite); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *text char + * + */ static void _clean_log_value(char *text) { if (text) { @@ -5150,6 +5368,17 @@ static PEP_STATUS _get_sequence_value(PEP_SESSION session, const char *name, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *name constchar + * + */ static PEP_STATUS _increment_sequence_value(PEP_SESSION session, const char *name) { diff --git a/src/pgp_sequoia.c b/src/pgp_sequoia.c index bd389f0f..04599208 100644 --- a/src/pgp_sequoia.c +++ b/src/pgp_sequoia.c @@ -133,6 +133,18 @@ int sq_sql_trace_callback (unsigned trace_constant, * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW */ #define PEP_MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *optr void + * @param[in] nmemb size_t + * @param[in] size size_t + * + */ static void* _pEp_reallocarray(void *optr, size_t nmemb, size_t size) { if ((nmemb >= PEP_MUL_NO_OVERFLOW || size >= PEP_MUL_NO_OVERFLOW) && @@ -169,6 +181,16 @@ PEP_STATUS pgp_config_cipher_suite(PEP_SESSION session, } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] suite PEP_CIPHER_SUITE + * + */ static pgp_cert_cipher_suite_t cipher_suite(PEP_CIPHER_SUITE suite) { switch (suite) { @@ -190,6 +212,20 @@ static pgp_cert_cipher_suite_t cipher_suite(PEP_CIPHER_SUITE suite) } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *cookie void + * @param[in] a_len int + * @param[in] *a constvoid + * @param[in] b_len int + * @param[in] *b constvoid + * + */ int email_cmp(void *cookie, int a_len, const void *a, int b_len, const void *b) { pgp_packet_t a_userid = pgp_user_id_from_raw (a, a_len); @@ -234,6 +270,18 @@ int email_cmp(void *cookie, int a_len, const void *a, int b_len, const void *b) return result; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] iter pgp_cert_valid_key_iter_t + * @param[in] *decrypted_key pgp_key_t + * + */ static PEP_STATUS _pgp_get_decrypted_key(PEP_SESSION session, pgp_cert_valid_key_iter_t iter, pgp_key_t* decrypted_key) { @@ -602,6 +650,16 @@ void pgp_release(PEP_SESSION session, bool out_last) // fingerprint doesn't contain any white space. // // This function does *not* consume fpr. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] * constchar + * + */ static char *pgp_fingerprint_canonicalize(const char *) __attribute__((nonnull)); static char *pgp_fingerprint_canonicalize(const char *fpr) { @@ -698,6 +756,20 @@ static PEP_STATUS key_loadn(PEP_SESSION session, sqlite3_stmt *stmt, // Returns the certificate identified by the provided fingerprint. // // This function only matches on the primary key! +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] pgp_fingerprint_t pgp_fingerprint_t + * @param[in] int int + * @param[in] * pgp_cert_t + * @param[in] * int + * + */ static PEP_STATUS cert_find(PEP_SESSION, pgp_fingerprint_t, int, pgp_cert_t *, int *) __attribute__((nonnull(1, 2))); static PEP_STATUS cert_find(PEP_SESSION session, @@ -734,6 +806,20 @@ static PEP_STATUS cert_find(PEP_SESSION session, // // If private_only is set, this will only consider certificates with some // secret key material. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] * constchar + * @param[in] int int + * @param[in] * pgp_cert_t + * @param[in] * int + * + */ static PEP_STATUS cert_find_by_keyid_hex(PEP_SESSION, const char *, int, pgp_cert_t *, int *) __attribute__((nonnull(1, 2))); static PEP_STATUS cert_find_by_keyid_hex( @@ -757,6 +843,20 @@ static PEP_STATUS cert_find_by_keyid_hex( } // See cert_find_by_keyid_hex. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] pgp_keyid_t pgp_keyid_t + * @param[in] int int + * @param[in] * pgp_cert_t + * @param[in] * int + * + */ PEP_STATUS cert_find_by_keyid(PEP_SESSION, pgp_keyid_t, int, pgp_cert_t *, int *) __attribute__((nonnull(1, 2))); PEP_STATUS cert_find_by_keyid(PEP_SESSION session, @@ -773,6 +873,20 @@ PEP_STATUS cert_find_by_keyid(PEP_SESSION session, } // See cert_find_by_keyid_hex. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] pgp_fingerprint_t pgp_fingerprint_t + * @param[in] int int + * @param[in] * pgp_cert_t + * @param[in] * int + * + */ static PEP_STATUS cert_find_by_fpr(PEP_SESSION, pgp_fingerprint_t, int, pgp_cert_t *, int *) __attribute__((nonnull(1, 2))); @@ -806,6 +920,19 @@ static PEP_STATUS cert_find_by_fpr_hex( } // Returns all known certificates. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] int int + * @param[in] ** pgp_cert_t + * @param[in] * int + * + */ static PEP_STATUS cert_all(PEP_SESSION, int, pgp_cert_t **, int *) __attribute__((nonnull)); static PEP_STATUS cert_all(PEP_SESSION session, int private_only, pgp_cert_t **certsp, int *certs_countp) { @@ -821,6 +948,20 @@ static PEP_STATUS cert_all(PEP_SESSION session, int private_only, // Returns keys that have a user id that matches the specified pattern. // // The keys returned must be freed using pgp_cert_free. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] PEP_SESSION PEP_SESSION + * @param[in] * constchar + * @param[in] int int + * @param[in] ** pgp_cert_t + * @param[in] * int + * + */ static PEP_STATUS cert_find_by_email(PEP_SESSION, const char *, int, pgp_cert_t **, int *) __attribute__((nonnull)); static PEP_STATUS cert_find_by_email(PEP_SESSION session, @@ -844,6 +985,19 @@ static PEP_STATUS cert_find_by_email(PEP_SESSION session, } // end detect possibly changed key stuff +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] **buffer_ptr void + * @param[in] *buffer_size_ptr size_t + * + */ static PEP_STATUS serialize_cert(PEP_SESSION session, pgp_cert_t cert, void** buffer_ptr, size_t* buffer_size_ptr) { @@ -1107,6 +1261,14 @@ static PEP_STATUS cert_save(PEP_SESSION session, pgp_cert_t cert, return status; } +/** + * @internal + * + * @struct decrypt_cookie + * + * @brief TODO + * + */ struct decrypt_cookie { PEP_SESSION session; int get_secret_keys_called; @@ -1408,6 +1570,17 @@ decrypt_cb(void *cookie_opaque, } static pgp_status_t +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *cookie_opaque void + * @param[in] structure pgp_message_structure_t + * + */ check_signatures_cb(void *cookie_opaque, pgp_message_structure_t structure) { struct decrypt_cookie *cookie = cookie_opaque; @@ -1625,6 +1798,17 @@ check_signatures_cb(void *cookie_opaque, pgp_message_structure_t structure) return PGP_STATUS_SUCCESS; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *cookie_opaque void + * @param[in] pp pgp_packet_parser_t + * + */ static pgp_status_t inspect_cb( void *cookie_opaque, pgp_packet_parser_t pp) { @@ -2009,6 +2193,22 @@ PEP_STATUS pgp_sign_only( return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *keylist conststringlist_t + * @param[in] *ptext constchar + * @param[in] psize size_t + * @param[in] **ctext char + * @param[in] *csize size_t + * @param[in] sign bool + * + */ static PEP_STATUS pgp_encrypt_sign_optional( PEP_SESSION session, const stringlist_t *keylist, const char *ptext, size_t psize, char **ctext, size_t *csize, bool sign) @@ -2253,6 +2453,16 @@ PEP_STATUS pgp_encrypt_and_sign( psize, ctext, csize, true); } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *input constchar + * + */ static char* _filter_parentheses(const char* input) { if (!input) return NULL; @@ -2279,6 +2489,16 @@ static char* _filter_parentheses(const char* input) { return retval; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *input constchar + * + */ static char* _flatten_to_alphanum(const char* input) { if (!input) return NULL; @@ -2303,6 +2523,18 @@ static char* _flatten_to_alphanum(const char* input) { return retval; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *identity pEp_identity + * @param[in] when time_t + * + */ PEP_STATUS _pgp_generate_keypair(PEP_SESSION session, pEp_identity *identity, time_t when) { PEP_STATUS status = PEP_STATUS_OK; @@ -2448,6 +2680,17 @@ PEP_STATUS pgp_delete_keypair(PEP_SESSION session, const char *fpr_raw) return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *key_data constchar + * @param[in] size size_t + * + */ static unsigned int count_keydata_parts(const char* key_data, size_t size) { unsigned int retval = 0; @@ -2801,6 +3044,16 @@ PEP_STATUS pgp_export_keydata( return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *address constchar + * + */ static char *_undot_address(const char* address) { if (!address) return NULL; @@ -2831,6 +3084,20 @@ static char *_undot_address(const char* address) { return retval; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *keyinfo_list stringpair_list_t + * @param[in] *keylist stringlist_t + * @param[in] cert pgp_cert_t + * @param[in] fpr pgp_fingerprint_t + * + */ static stringpair_list_t *add_key(PEP_SESSION session, stringpair_list_t *keyinfo_list, stringlist_t* keylist, @@ -2873,6 +3140,20 @@ static stringpair_list_t *add_key(PEP_SESSION session, return keyinfo_list; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] *pattern constchar + * @param[in] private_only int + * @param[in] **keyinfo_list stringpair_list_t + * @param[in] **keylist stringlist_t + * + */ static PEP_STATUS list_keys(PEP_SESSION session, const char* pattern, int private_only, stringpair_list_t** keyinfo_list, stringlist_t** keylist) @@ -3225,6 +3506,18 @@ PEP_STATUS pgp_revoke_key( // NOTE: Doesn't check the *validity* of these subkeys. Just checks to see // if they exist. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] *has_subkey bool + * + */ static void _pgp_contains_encryption_subkey(PEP_SESSION session, pgp_cert_t cert, bool* has_subkey) { pgp_cert_valid_key_iter_t key_iter = pgp_cert_valid_key_iter(cert, session->policy, 0); @@ -3242,6 +3535,18 @@ static void _pgp_contains_encryption_subkey(PEP_SESSION session, pgp_cert_t cert // NOTE: Doesn't check the *validity* of these subkeys. Just checks to see // if they exist. +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] *has_subkey bool + * + */ static void _pgp_contains_sig_subkey(PEP_SESSION session, pgp_cert_t cert, bool* has_subkey) { pgp_cert_valid_key_iter_t key_iter = pgp_cert_valid_key_iter(cert, session->policy, 0); @@ -3256,6 +3561,18 @@ static void _pgp_contains_sig_subkey(PEP_SESSION session, pgp_cert_t cert, bool* } // Check to see that key, at a minimum, even contains encryption or signing subkeys +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] *is_broken bool + * + */ static void _pgp_key_broken(PEP_SESSION session, pgp_cert_t cert, bool* is_broken) { *is_broken = false; bool unbroken = false; @@ -3269,6 +3586,19 @@ static void _pgp_key_broken(PEP_SESSION session, pgp_cert_t cert, bool* is_broke } } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] when consttime_t + * @param[in] *expired bool + * + */ static void _pgp_key_expired(PEP_SESSION session, pgp_cert_t cert, const time_t when, bool* expired) { // Is the certificate live? @@ -3371,6 +3701,18 @@ PEP_STATUS pgp_key_expired(PEP_SESSION session, const char *fpr, return status; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] session PEP_SESSION + * @param[in] cert pgp_cert_t + * @param[in] *revoked bool + * + */ static void _pgp_key_revoked(PEP_SESSION session, pgp_cert_t cert, bool* revoked) { pgp_revocation_status_t rs = pgp_cert_revocation_status(cert, session->policy, 0); *revoked = pgp_revocation_status_variant(rs) == PGP_REVOCATION_STATUS_REVOKED; diff --git a/src/platform_unix.c b/src/platform_unix.c index 2c5064d6..78d34cea 100644 --- a/src/platform_unix.c +++ b/src/platform_unix.c @@ -250,6 +250,17 @@ char *strnstr(const char *big, const char *little, size_t len) { #endif +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] **first char + * @param[in] *second constchar + * + */ static char *_stradd(char **first, const char *second) { assert(first && *first && second); @@ -270,12 +281,34 @@ static char *_stradd(char **first, const char *second) return *first; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] **p char + * + */ static void _empty(char **p) { free(*p); *p = NULL; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *o constchar + * @param[in] *ext constchar + * @param[in] *n constchar + * + */ static void _move(const char *o, const char *ext, const char *n) { assert(o && ext && n); @@ -309,6 +342,16 @@ static void _move(const char *o, const char *ext, const char *n) } #ifndef NDEBUG +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] reset int + * + */ static const char *_per_user_directory(int reset) #else static const char *_per_user_directory(void) diff --git a/src/stringlist.c b/src/stringlist.c index 35384e86..6109e55c 100644 --- a/src/stringlist.c +++ b/src/stringlist.c @@ -56,6 +56,18 @@ DYNAMIC_API stringlist_t *stringlist_dup(const stringlist_t *src) return dst; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *stringlist stringlist_t + * @param[in] **result stringlist_t + * @param[in] *value constchar + * + */ static bool _stringlist_add_first( stringlist_t *stringlist, stringlist_t **result, @@ -237,6 +249,17 @@ DYNAMIC_API stringlist_t *stringlist_delete( return stringlist; } +/** + * @internal + * + * + * + * @brief TODO + * + * @param[in] *stringlist stringlist_t + * @param[in] *value constchar + * + */ static stringlist_t* stringlist_multi_delete(stringlist_t* stringlist, const char* value) { if (stringlist == NULL || !stringlist->value) return stringlist;