NeoMutt  2021-02-05
Teaching an old dog new tricks
DOXYGEN
lib.h File Reference

Autocrypt end-to-end encryption. More...

#include <stdbool.h>
#include <sqlite3.h>
#include <stdio.h>
+ Include dependency graph for lib.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  AutocryptAccount
 Autocrypt account. More...
 
struct  AutocryptPeer
 Autocrypt peer. More...
 
struct  AutocryptPeerHistory
 Autocrypt peer history. More...
 
struct  AutocryptGossipHistory
 Autocrypt gossip history. More...
 

Enumerations

enum  AutocryptRec {
  AUTOCRYPT_REC_OFF, AUTOCRYPT_REC_NO, AUTOCRYPT_REC_DISCOURAGE, AUTOCRYPT_REC_AVAILABLE,
  AUTOCRYPT_REC_YES
}
 Recommendation. More...
 

Functions

void dlg_select_autocrypt_account (void)
 Display the Autocrypt account Menu. More...
 
void mutt_autocrypt_cleanup (void)
 Shutdown Autocrypt. More...
 
int mutt_autocrypt_generate_gossip_list (struct Email *e)
 Create the gossip list headers. More...
 
int mutt_autocrypt_init (bool can_create)
 Initialise Autocrypt. More...
 
int mutt_autocrypt_process_autocrypt_header (struct Email *e, struct Envelope *env)
 Parse an Autocrypt email header. More...
 
int mutt_autocrypt_process_gossip_header (struct Email *e, struct Envelope *prot_headers)
 Parse an Autocrypt email gossip header. More...
 
int mutt_autocrypt_set_sign_as_default_key (struct Email *e)
 Set the Autocrypt default key for signing. More...
 
enum AutocryptRec mutt_autocrypt_ui_recommendation (struct Email *e, char **keylist)
 Get the recommended action for an Email. More...
 
int mutt_autocrypt_write_autocrypt_header (struct Envelope *env, FILE *fp)
 Write the Autocrypt header to a file. More...
 
int mutt_autocrypt_write_gossip_headers (struct Envelope *env, FILE *fp)
 Write the Autocrypt gossip headers to a file. More...
 

Variables

char * AutocryptSignAs
 Autocrypt Key id to sign as. More...
 
char * AutocryptDefaultKey
 Autocrypt default key id (used for postponing messages) More...
 
bool C_Autocrypt
 Config: Enables the Autocrypt feature. More...
 
bool C_AutocryptReply
 Config: Replying to an autocrypt email automatically enables autocrypt in the reply. More...
 
char * C_AutocryptAcctFormat
 Config: Format of the autocrypt account menu. More...
 
char * C_AutocryptDir
 Config: Location of autocrypt files, including the GPG keyring and SQLite database. More...
 

Detailed Description

Autocrypt end-to-end encryption.

Authors
  • Kevin J. McCarthy

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file lib.h.

Enumeration Type Documentation

◆ AutocryptRec

Recommendation.

Enumerator
AUTOCRYPT_REC_OFF 

No recommendations.

AUTOCRYPT_REC_NO 

Do no use Autocrypt.

AUTOCRYPT_REC_DISCOURAGE 

Prefer not to use Autocrypt.

AUTOCRYPT_REC_AVAILABLE 

Autocrypt is available.

AUTOCRYPT_REC_YES 

Autocrypt should be used.

Definition at line 154 of file lib.h.

155 {
161 };
Autocrypt should be used.
Definition: lib.h:160
No recommendations.
Definition: lib.h:156
Do no use Autocrypt.
Definition: lib.h:157
Prefer not to use Autocrypt.
Definition: lib.h:158
Autocrypt is available.
Definition: lib.h:159

Function Documentation

◆ dlg_select_autocrypt_account()

void dlg_select_autocrypt_account ( void  )

Display the Autocrypt account Menu.

Definition at line 256 of file dlgautocrypt.c.

257 {
258  if (!C_Autocrypt)
259  return;
260 
261  if (mutt_autocrypt_init(false))
262  return;
263 
264  struct Menu *menu = create_menu();
265  if (!menu)
266  return;
267 
271 
272  bool done = false;
273  while (!done)
274  {
275  switch (mutt_menu_loop(menu))
276  {
277  case OP_EXIT:
278  done = true;
279  break;
280 
281  case OP_AUTOCRYPT_CREATE_ACCT:
282  if (mutt_autocrypt_account_init(false))
283  break;
284 
285  menu_free(&menu);
287  menu = create_menu();
291  break;
292 
293  case OP_AUTOCRYPT_DELETE_ACCT:
294  {
295  if (!menu->mdata)
296  break;
297 
298  struct AccountEntry *entry = (struct AccountEntry *) (menu->mdata) + menu->current;
299  char msg[128];
300  snprintf(msg, sizeof(msg),
301  // L10N: Confirmation message when deleting an autocrypt account
302  _("Really delete account \"%s\"?"), entry->addr->mailbox);
303  if (mutt_yesorno(msg, MUTT_NO) != MUTT_YES)
304  break;
305 
307  {
308  menu_free(&menu);
310  menu = create_menu();
314  }
315  break;
316  }
317 
318  case OP_AUTOCRYPT_TOGGLE_ACTIVE:
319  {
320  if (!menu->mdata)
321  break;
322 
323  struct AccountEntry *entry = (struct AccountEntry *) (menu->mdata) + menu->current;
324  toggle_active(entry);
325  menu->redraw |= REDRAW_FULL;
326  break;
327  }
328 
329  case OP_AUTOCRYPT_TOGGLE_PREFER:
330  {
331  if (!menu->mdata)
332  break;
333 
334  struct AccountEntry *entry = (struct AccountEntry *) (menu->mdata) + menu->current;
335  toggle_prefer_encrypt(entry);
336  menu->redraw |= REDRAW_FULL;
337  break;
338  }
339  }
340  }
341 
342  menu_free(&menu);
344 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
#define REDRAW_FULL
Redraw everything.
Definition: mutt_menu.h:45
GUI selectable list of items.
Definition: mutt_menu.h:52
int help_menu
Menu for key bindings, e.g. MENU_PAGER.
Definition: mutt_window.h:134
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
static const struct Mapping AutocryptAcctHelp[]
Help Bar for the Autocrypt Account selection dialog.
Definition: dlgautocrypt.c:59
#define _(a)
Definition: message.h:28
Autocrypt Account menu.
Definition: keymap.h:94
char * mailbox
Mailbox and host address.
Definition: address.h:37
A division of the screen.
Definition: mutt_window.h:115
static void toggle_prefer_encrypt(struct AccountEntry *entry)
Toggle whether an Autocrypt account prefers encryption.
Definition: dlgautocrypt.c:243
struct MuttWindow * dialog_create_simple_index(struct Menu *menu, enum WindowType type)
Create a simple index Dialog.
Definition: dialog.c:165
int mutt_autocrypt_account_init(bool prompt)
Create a new Autocrypt account.
Definition: autocrypt.c:147
int mutt_autocrypt_db_account_delete(struct AutocryptAccount *acct)
Delete an Account from the Autocrypt database.
Definition: db.c:415
enum QuadOption mutt_yesorno(const char *msg, enum QuadOption def)
Ask the user a Yes/No question.
Definition: curs_lib.c:379
static void menu_free(struct Menu **menu)
Free the Autocrypt account Menu.
Definition: dlgautocrypt.c:208
An entry in the Autocrypt account Menu.
Definition: dlgautocrypt.c:50
Autocrypt Dialog, dlg_select_autocrypt_account()
Definition: mutt_window.h:76
static void toggle_active(struct AccountEntry *entry)
Toggle whether an Autocrypt account is active.
Definition: dlgautocrypt.c:227
void * mdata
Extra data for the current menu.
Definition: mutt_menu.h:55
struct Address * addr
Definition: dlgautocrypt.c:55
const struct Mapping * help_data
Data for the Help Bar.
Definition: mutt_window.h:135
void dialog_destroy_simple_index(struct MuttWindow **ptr)
Destroy a simple index Dialog.
Definition: dialog.c:209
MuttRedrawFlags redraw
When to redraw the screen.
Definition: mutt_menu.h:58
struct AutocryptAccount * account
Definition: dlgautocrypt.c:54
static struct Menu * create_menu(void)
Create the Autocrypt account Menu.
Definition: dlgautocrypt.c:166
User answered &#39;No&#39;, or assume &#39;No&#39;.
Definition: quad.h:39
int current
Current entry.
Definition: mutt_menu.h:56
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_cleanup()

void mutt_autocrypt_cleanup ( void  )

Shutdown Autocrypt.

Definition at line 133 of file autocrypt.c.

134 {
136 }
void mutt_autocrypt_db_close(void)
Close the Autocrypt SQLite database connection.
Definition: db.c:126
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_generate_gossip_list()

int mutt_autocrypt_generate_gossip_list ( struct Email e)

Create the gossip list headers.

Parameters
eEmail
Return values
0Success
-1Error

Definition at line 811 of file autocrypt.c.

812 {
813  int rc = -1;
814  struct AutocryptPeer *peer = NULL;
815  struct AutocryptAccount *account = NULL;
816  struct Address *recip = NULL;
817 
818  if (!C_Autocrypt || mutt_autocrypt_init(false) || !e)
819  return -1;
820 
821  struct Envelope *mime_headers = e->body->mime_headers;
822  if (!mime_headers)
823  mime_headers = e->body->mime_headers = mutt_env_new();
825 
826  struct AddressList recips = TAILQ_HEAD_INITIALIZER(recips);
827 
828  mutt_addrlist_copy(&recips, &e->env->to, false);
829  mutt_addrlist_copy(&recips, &e->env->cc, false);
830 
831  TAILQ_FOREACH(recip, &recips, entries)
832  {
833  /* At this point, we just accept missing keys and include what we can. */
834  if (mutt_autocrypt_db_peer_get(recip, &peer) <= 0)
835  continue;
836 
837  const char *keydata = NULL;
839  keydata = peer->keydata;
841  keydata = peer->gossip_keydata;
842 
843  if (keydata)
844  {
845  struct AutocryptHeader *gossip = mutt_autocrypthdr_new();
846  gossip->addr = mutt_str_dup(peer->email_addr);
847  gossip->keydata = mutt_str_dup(keydata);
848  gossip->next = mime_headers->autocrypt_gossip;
849  mime_headers->autocrypt_gossip = gossip;
850  }
851 
853  }
854 
855  TAILQ_FOREACH(recip, &e->env->reply_to, entries)
856  {
857  const char *addr = NULL;
858  const char *keydata = NULL;
859  if (mutt_autocrypt_db_account_get(recip, &account) > 0)
860  {
861  addr = account->email_addr;
862  keydata = account->keydata;
863  }
864  else if (mutt_autocrypt_db_peer_get(recip, &peer) > 0)
865  {
866  addr = peer->email_addr;
868  keydata = peer->keydata;
870  keydata = peer->gossip_keydata;
871  }
872 
873  if (keydata)
874  {
875  struct AutocryptHeader *gossip = mutt_autocrypthdr_new();
876  gossip->addr = mutt_str_dup(addr);
877  gossip->keydata = mutt_str_dup(keydata);
878  gossip->next = mime_headers->autocrypt_gossip;
879  mime_headers->autocrypt_gossip = gossip;
880  }
883  }
884 
885  mutt_addrlist_clear(&recips);
888  return rc;
889 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
struct Body * body
List of MIME parts.
Definition: email.h:91
struct AutocryptHeader * autocrypt_gossip
Definition: envelope.h:86
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
Definition: db.c:240
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1468
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
char * keydata
Definition: lib.h:121
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
An email address.
Definition: address.h:34
struct AutocryptHeader * mutt_autocrypthdr_new(void)
Create a new AutocryptHeader.
Definition: envelope.c:65
char * email_addr
Definition: lib.h:105
char * gossip_keydata
Definition: lib.h:125
Autocrypt peer.
Definition: lib.h:115
char * keydata
Definition: envelope.h:44
struct Envelope * env
Envelope information.
Definition: email.h:90
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
char * email_addr
Definition: lib.h:117
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
bool mutt_autocrypt_gpgme_is_valid_key(const char *keyid)
Is a key id valid?
Definition: gpgme.c:355
struct AutocryptHeader * next
Definition: envelope.h:47
char * gossip_keyid
Definition: lib.h:124
char * addr
Definition: envelope.h:43
Parse Autocrypt header info.
Definition: envelope.h:41
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
Definition: db.c:259
Autocrypt account.
Definition: lib.h:103
void mutt_autocrypthdr_free(struct AutocryptHeader **p)
Free an AutocryptHeader.
Definition: envelope.c:74
char * keydata
Definition: lib.h:107
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
Definition: db.c:524
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
char * keyid
Definition: lib.h:120
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the Autocrypt database.
Definition: db.c:546
The header of an Email.
Definition: envelope.h:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_init()

int mutt_autocrypt_init ( bool  can_create)

Initialise Autocrypt.

Parameters
can_createIf true, directories may be created
Return values
0Success
-1Error

Definition at line 93 of file autocrypt.c.

94 {
95  if (AutocryptDB)
96  return 0;
97 
98  if (!C_Autocrypt || !C_AutocryptDir)
99  return -1;
100 
101  OptIgnoreMacroEvents = true;
102  /* The init process can display menus at various points
103  *(e.g. browser, pgp key selection). This allows the screen to be
104  * autocleared after each menu, so the subsequent prompts can be
105  * read. */
106  OptMenuPopClearScreen = true;
107 
108  if (autocrypt_dir_init(can_create))
109  goto bail;
110 
112  goto bail;
113 
114  if (mutt_autocrypt_db_init(can_create))
115  goto bail;
116 
117  OptIgnoreMacroEvents = false;
118  OptMenuPopClearScreen = false;
119 
120  return 0;
121 
122 bail:
123  OptIgnoreMacroEvents = false;
124  OptMenuPopClearScreen = false;
125  C_Autocrypt = false;
127  return -1;
128 }
char * C_AutocryptDir
Config: Location of autocrypt files, including the GPG keyring and SQLite database.
Definition: config.c:40
void mutt_autocrypt_db_close(void)
Close the Autocrypt SQLite database connection.
Definition: db.c:126
sqlite3 * AutocryptDB
Definition: db.c:50
int mutt_autocrypt_gpgme_init(void)
Initialise GPGME.
Definition: gpgme.c:65
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
static int autocrypt_dir_init(bool can_create)
Initialise an Autocrypt directory.
Definition: autocrypt.c:56
WHERE bool OptIgnoreMacroEvents
(pseudo) don&#39;t process macro/push/exec events while set
Definition: options.h:38
int mutt_autocrypt_db_init(bool can_create)
Initialise the Autocrypt SQLite database.
Definition: db.c:77
WHERE bool OptMenuPopClearScreen
(pseudo) clear the screen when popping the last menu
Definition: options.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_process_autocrypt_header()

int mutt_autocrypt_process_autocrypt_header ( struct Email e,
struct Envelope env 
)

Parse an Autocrypt email header.

Parameters
eEmail
envEnvelope
Return values
0Success
-1Error

Definition at line 253 of file autocrypt.c.

254 {
255  struct AutocryptHeader *valid_ac_hdr = NULL;
256  struct AutocryptPeer *peer = NULL;
257  struct AutocryptPeerHistory *peerhist = NULL;
258  struct Buffer *keyid = NULL;
259  bool update_db = false, insert_db = false, insert_db_history = false, import_gpg = false;
260  int rc = -1;
261 
262  if (!C_Autocrypt)
263  return 0;
264 
265  if (mutt_autocrypt_init(false))
266  return -1;
267 
268  if (!e || !e->body || !env)
269  return 0;
270 
271  /* 1.1 spec says to skip emails with more than one From header */
272  struct Address *from = TAILQ_FIRST(&env->from);
273  if (!from || TAILQ_NEXT(from, entries))
274  return 0;
275 
276  /* 1.1 spec also says to skip multipart/report emails */
277  if ((e->body->type == TYPE_MULTIPART) &&
278  mutt_istr_equal(e->body->subtype, "report"))
279  {
280  return 0;
281  }
282 
283  /* Ignore emails that appear to be more than a week in the future,
284  * since they can block all future updates during that time. */
285  if (e->date_sent > (mutt_date_epoch() + (7 * 24 * 60 * 60)))
286  return 0;
287 
288  for (struct AutocryptHeader *ac_hdr = env->autocrypt; ac_hdr; ac_hdr = ac_hdr->next)
289  {
290  if (ac_hdr->invalid)
291  continue;
292 
293  /* NOTE: this assumes the processing is occurring right after
294  * mutt_parse_rfc822_line() and the from ADDR is still in the same
295  * form (intl) as the autocrypt header addr field */
296  if (!mutt_istr_equal(from->mailbox, ac_hdr->addr))
297  continue;
298 
299  /* 1.1 spec says ignore all, if more than one valid header is found. */
300  if (valid_ac_hdr)
301  {
302  valid_ac_hdr = NULL;
303  break;
304  }
305  valid_ac_hdr = ac_hdr;
306  }
307 
308  if (mutt_autocrypt_db_peer_get(from, &peer) < 0)
309  goto cleanup;
310 
311  if (peer)
312  {
313  if (e->date_sent <= peer->autocrypt_timestamp)
314  {
315  rc = 0;
316  goto cleanup;
317  }
318 
319  if (e->date_sent > peer->last_seen)
320  {
321  update_db = true;
322  peer->last_seen = e->date_sent;
323  }
324 
325  if (valid_ac_hdr)
326  {
327  update_db = true;
328  peer->autocrypt_timestamp = e->date_sent;
329  peer->prefer_encrypt = valid_ac_hdr->prefer_encrypt;
330  if (!mutt_str_equal(peer->keydata, valid_ac_hdr->keydata))
331  {
332  import_gpg = true;
333  insert_db_history = true;
334  mutt_str_replace(&peer->keydata, valid_ac_hdr->keydata);
335  }
336  }
337  }
338  else if (valid_ac_hdr)
339  {
340  import_gpg = true;
341  insert_db = true;
342  insert_db_history = true;
343  }
344 
345  if (!(import_gpg || insert_db || update_db))
346  {
347  rc = 0;
348  goto cleanup;
349  }
350 
351  if (!peer)
352  {
354  peer->last_seen = e->date_sent;
355  peer->autocrypt_timestamp = e->date_sent;
356  peer->keydata = mutt_str_dup(valid_ac_hdr->keydata);
357  peer->prefer_encrypt = valid_ac_hdr->prefer_encrypt;
358  }
359 
360  if (import_gpg)
361  {
362  keyid = mutt_buffer_pool_get();
363  if (mutt_autocrypt_gpgme_import_key(peer->keydata, keyid))
364  goto cleanup;
365  mutt_str_replace(&peer->keyid, mutt_buffer_string(keyid));
366  }
367 
368  if (insert_db && mutt_autocrypt_db_peer_insert(from, peer))
369  goto cleanup;
370 
371  if (update_db && mutt_autocrypt_db_peer_update(peer))
372  goto cleanup;
373 
374  if (insert_db_history)
375  {
377  peerhist->email_msgid = mutt_str_dup(env->message_id);
378  peerhist->timestamp = e->date_sent;
379  peerhist->keydata = mutt_str_dup(peer->keydata);
380  if (mutt_autocrypt_db_peer_history_insert(from, peerhist))
381  goto cleanup;
382  }
383 
384  rc = 0;
385 
386 cleanup:
389  mutt_buffer_pool_release(&keyid);
390 
391  return rc;
392 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
struct AutocryptPeerHistory * mutt_autocrypt_db_peer_history_new(void)
Create a new AutocryptPeerHistory.
Definition: db.c:730
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define TAILQ_FIRST(head)
Definition: queue.h:716
struct Body * body
List of MIME parts.
Definition: email.h:91
bool prefer_encrypt
Definition: envelope.h:45
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
char * email_msgid
Definition: lib.h:134
char * keydata
Definition: lib.h:121
sqlite3_int64 timestamp
Definition: lib.h:135
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct AutocryptPeer * mutt_autocrypt_db_peer_new(void)
Create a new AutocryptPeer.
Definition: db.c:515
String manipulation buffer.
Definition: buffer.h:33
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
An email address.
Definition: address.h:34
struct AutocryptHeader * autocrypt
Definition: envelope.h:85
char * mailbox
Mailbox and host address.
Definition: address.h:37
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
sqlite3_int64 autocrypt_timestamp
Definition: lib.h:119
char * message_id
Message ID.
Definition: envelope.h:69
Autocrypt peer.
Definition: lib.h:115
char * keydata
Definition: envelope.h:44
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
char * subtype
content-type subtype
Definition: body.h:37
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:82
sqlite3_int64 last_seen
Definition: lib.h:118
int mutt_autocrypt_db_peer_insert(struct Address *addr, struct AutocryptPeer *peer)
Insert a peer into the Autocrypt database.
Definition: db.c:611
struct AutocryptHeader * next
Definition: envelope.h:47
Autocrypt peer history.
Definition: lib.h:131
Parse Autocrypt header info.
Definition: envelope.h:41
unsigned int type
content-type primary type, ContentType
Definition: body.h:65
int mutt_autocrypt_db_peer_history_insert(struct Address *addr, struct AutocryptPeerHistory *peerhist)
Insert peer history into the Autocrypt database.
Definition: db.c:758
bool prefer_encrypt
false = nopref, true = mutual
Definition: lib.h:122
char * keydata
Definition: lib.h:136
int mutt_autocrypt_db_peer_update(struct AutocryptPeer *peer)
Update the peer info in an Autocrypt database.
Definition: db.c:674
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
Definition: db.c:524
#define TAILQ_NEXT(elm, field)
Definition: queue.h:825
void mutt_autocrypt_db_peer_history_free(struct AutocryptPeerHistory **ptr)
Free an AutocryptPeerHistory.
Definition: db.c:739
char * keyid
Definition: lib.h:120
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the Autocrypt database.
Definition: db.c:546
int mutt_autocrypt_gpgme_import_key(const char *keydata, struct Buffer *keyid)
Read a key from GPGME.
Definition: gpgme.c:314
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_process_gossip_header()

int mutt_autocrypt_process_gossip_header ( struct Email e,
struct Envelope prot_headers 
)

Parse an Autocrypt email gossip header.

Parameters
eEmail
prot_headersEnvelope with protected headers
Return values
0Success
-1Error

Definition at line 401 of file autocrypt.c.

402 {
403  struct AutocryptPeer *peer = NULL;
404  struct AutocryptGossipHistory *gossip_hist = NULL;
405  struct Address *peer_addr = NULL;
406  struct Address ac_hdr_addr = { 0 };
407  bool update_db = false, insert_db = false, insert_db_history = false, import_gpg = false;
408  int rc = -1;
409 
410  if (!C_Autocrypt)
411  return 0;
412 
413  if (mutt_autocrypt_init(false))
414  return -1;
415 
416  if (!e || !e->env || !prot_headers)
417  return 0;
418 
419  struct Envelope *env = e->env;
420 
421  struct Address *from = TAILQ_FIRST(&env->from);
422  if (!from)
423  return 0;
424 
425  /* Ignore emails that appear to be more than a week in the future,
426  * since they can block all future updates during that time. */
427  if (e->date_sent > (mutt_date_epoch() + (7 * 24 * 60 * 60)))
428  return 0;
429 
430  struct Buffer *keyid = mutt_buffer_pool_get();
431 
432  struct AddressList recips = TAILQ_HEAD_INITIALIZER(recips);
433 
434  /* Normalize the recipient list for comparison */
435  mutt_addrlist_copy(&recips, &env->to, false);
436  mutt_addrlist_copy(&recips, &env->cc, false);
437  mutt_addrlist_copy(&recips, &env->reply_to, false);
439 
440  for (struct AutocryptHeader *ac_hdr = prot_headers->autocrypt_gossip; ac_hdr;
441  ac_hdr = ac_hdr->next)
442  {
443  if (ac_hdr->invalid)
444  continue;
445 
446  /* normalize for comparison against recipient list */
447  mutt_str_replace(&ac_hdr_addr.mailbox, ac_hdr->addr);
448  ac_hdr_addr.is_intl = true;
449  ac_hdr_addr.intl_checked = true;
450  mutt_autocrypt_db_normalize_addr(&ac_hdr_addr);
451 
452  /* Check to make sure the address is in the recipient list. */
453  TAILQ_FOREACH(peer_addr, &recips, entries)
454  {
455  if (mutt_str_equal(peer_addr->mailbox, ac_hdr_addr.mailbox))
456  break;
457  }
458 
459  if (!peer_addr)
460  continue;
461 
462  if (mutt_autocrypt_db_peer_get(peer_addr, &peer) < 0)
463  goto cleanup;
464 
465  if (peer)
466  {
467  if (e->date_sent <= peer->gossip_timestamp)
468  {
470  continue;
471  }
472 
473  update_db = true;
474  peer->gossip_timestamp = e->date_sent;
475  /* This is slightly different from the autocrypt 1.1 spec.
476  * Avoid setting an empty peer.gossip_keydata with a value that matches
477  * the current peer.keydata. */
478  if ((peer->gossip_keydata && !mutt_str_equal(peer->gossip_keydata, ac_hdr->keydata)) ||
479  (!peer->gossip_keydata && !mutt_str_equal(peer->keydata, ac_hdr->keydata)))
480  {
481  import_gpg = true;
482  insert_db_history = true;
483  mutt_str_replace(&peer->gossip_keydata, ac_hdr->keydata);
484  }
485  }
486  else
487  {
488  import_gpg = true;
489  insert_db = true;
490  insert_db_history = true;
491  }
492 
493  if (!peer)
494  {
496  peer->gossip_timestamp = e->date_sent;
497  peer->gossip_keydata = mutt_str_dup(ac_hdr->keydata);
498  }
499 
500  if (import_gpg)
501  {
503  goto cleanup;
505  }
506 
507  if (insert_db && mutt_autocrypt_db_peer_insert(peer_addr, peer))
508  goto cleanup;
509 
510  if (update_db && mutt_autocrypt_db_peer_update(peer))
511  goto cleanup;
512 
513  if (insert_db_history)
514  {
515  gossip_hist = mutt_autocrypt_db_gossip_history_new();
516  gossip_hist->sender_email_addr = mutt_str_dup(from->mailbox);
517  gossip_hist->email_msgid = mutt_str_dup(env->message_id);
518  gossip_hist->timestamp = e->date_sent;
519  gossip_hist->gossip_keydata = mutt_str_dup(peer->gossip_keydata);
520  if (mutt_autocrypt_db_gossip_history_insert(peer_addr, gossip_hist))
521  goto cleanup;
522  }
523 
526  mutt_buffer_reset(keyid);
527  update_db = false;
528  insert_db = false;
529  insert_db_history = false;
530  import_gpg = false;
531  }
532 
533  rc = 0;
534 
535 cleanup:
536  FREE(&ac_hdr_addr.mailbox);
537  mutt_addrlist_clear(&recips);
540  mutt_buffer_pool_release(&keyid);
541 
542  return rc;
543 }
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
void mutt_autocrypt_db_normalize_addr(struct Address *a)
Normalise an Email Address.
Definition: db.c:161
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:79
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define TAILQ_FIRST(head)
Definition: queue.h:716
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
struct AutocryptHeader * autocrypt_gossip
Definition: envelope.h:86
struct AddressList reply_to
Email&#39;s &#39;reply-to&#39;.
Definition: envelope.h:62
void mutt_autocrypt_db_gossip_history_free(struct AutocryptGossipHistory **ptr)
Free an AutocryptGossipHistory.
Definition: db.c:815
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1468
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
char * keydata
Definition: lib.h:121
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
struct AutocryptPeer * mutt_autocrypt_db_peer_new(void)
Create a new AutocryptPeer.
Definition: db.c:515
String manipulation buffer.
Definition: buffer.h:33
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
char * gossip_keydata
Definition: lib.h:125
bool is_intl
International Domain Name.
Definition: address.h:39
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
sqlite3_int64 gossip_timestamp
Definition: lib.h:123
char * sender_email_addr
Definition: lib.h:145
char * message_id
Message ID.
Definition: envelope.h:69
Autocrypt peer.
Definition: lib.h:115
char * email_msgid
Definition: lib.h:146
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct Envelope * env
Envelope information.
Definition: email.h:90
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
bool intl_checked
Checked for IDN?
Definition: address.h:40
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:82
Autocrypt gossip history.
Definition: lib.h:142
int mutt_autocrypt_db_peer_insert(struct Address *addr, struct AutocryptPeer *peer)
Insert a peer into the Autocrypt database.
Definition: db.c:611
struct AutocryptHeader * next
Definition: envelope.h:47
char * gossip_keyid
Definition: lib.h:124
struct AutocryptGossipHistory * mutt_autocrypt_db_gossip_history_new(void)
Create a new AutocryptGossipHistory.
Definition: db.c:806
Parse Autocrypt header info.
Definition: envelope.h:41
void mutt_autocrypt_db_normalize_addrlist(struct AddressList *al)
Normalise a list of Email Addresses.
Definition: db.c:172
int mutt_autocrypt_db_peer_update(struct AutocryptPeer *peer)
Update the peer info in an Autocrypt database.
Definition: db.c:674
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
#define FREE(x)
Definition: memory.h:40
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
Definition: db.c:524
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
char * gossip_keydata
Definition: lib.h:148
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the Autocrypt database.
Definition: db.c:546
int mutt_autocrypt_db_gossip_history_insert(struct Address *addr, struct AutocryptGossipHistory *gossip_hist)
Insert a gossip history into the Autocrypt database.
Definition: db.c:835
sqlite3_int64 timestamp
Definition: lib.h:147
The header of an Email.
Definition: envelope.h:54
int mutt_autocrypt_gpgme_import_key(const char *keydata, struct Buffer *keyid)
Read a key from GPGME.
Definition: gpgme.c:314
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_set_sign_as_default_key()

int mutt_autocrypt_set_sign_as_default_key ( struct Email e)

Set the Autocrypt default key for signing.

Parameters
eEmail
Return values
0Success
-1Error

Definition at line 688 of file autocrypt.c.

689 {
690  int rc = -1;
691  struct AutocryptAccount *account = NULL;
692 
693  if (!C_Autocrypt || mutt_autocrypt_init(false) || !e)
694  return -1;
695 
696  struct Address *from = TAILQ_FIRST(&e->env->from);
697  if (!from || TAILQ_NEXT(from, entries))
698  return -1;
699 
700  if (mutt_autocrypt_db_account_get(from, &account) <= 0)
701  goto cleanup;
702  if (!account->keyid)
703  goto cleanup;
704  if (!account->enabled)
705  goto cleanup;
706 
709 
710  rc = 0;
711 
712 cleanup:
714  return rc;
715 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
#define TAILQ_FIRST(head)
Definition: queue.h:716
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
Definition: db.c:240
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
An email address.
Definition: address.h:34
char * AutocryptSignAs
Autocrypt Key id to sign as.
Definition: config.c:42
char * AutocryptDefaultKey
Autocrypt default key id (used for postponing messages)
Definition: config.c:43
char * keyid
Definition: lib.h:106
bool enabled
Definition: lib.h:109
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct Envelope * env
Envelope information.
Definition: email.h:90
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
Definition: db.c:259
Autocrypt account.
Definition: lib.h:103
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
#define TAILQ_NEXT(elm, field)
Definition: queue.h:825
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_ui_recommendation()

enum AutocryptRec mutt_autocrypt_ui_recommendation ( struct Email e,
char **  keylist 
)

Get the recommended action for an Email.

Parameters
[in]eEmail
[out]keylistList of Autocrypt key ids
Return values
numRecommendation, e.g. AUTOCRYPT_REC_AVAILABLE

If the recommendataion is > NO and keylist is not NULL, keylist will be populated with the autocrypt keyids.

Definition at line 554 of file autocrypt.c.

555 {
557  struct AutocryptAccount *account = NULL;
558  struct AutocryptPeer *peer = NULL;
559  struct Address *recip = NULL;
560  bool all_encrypt = true, has_discourage = false;
561  const char *matching_key = NULL;
562  struct AddressList recips = TAILQ_HEAD_INITIALIZER(recips);
563  struct Buffer *keylist_buf = NULL;
564 
565  if (!C_Autocrypt || mutt_autocrypt_init(false) || !e)
566  {
567  if (keylist)
568  {
569  /* L10N: Error displayed if the user tries to force sending an Autocrypt
570  email when the engine is not available. */
571  mutt_message(_("Autocrypt is not available"));
572  }
573  return AUTOCRYPT_REC_OFF;
574  }
575 
576  struct Address *from = TAILQ_FIRST(&e->env->from);
577  if (!from || TAILQ_NEXT(from, entries))
578  {
579  if (keylist)
580  mutt_message(_("Autocrypt is not available"));
581  return AUTOCRYPT_REC_OFF;
582  }
583 
584  if (e->security & APPLICATION_SMIME)
585  {
586  if (keylist)
587  mutt_message(_("Autocrypt is not available"));
588  return AUTOCRYPT_REC_OFF;
589  }
590 
591  if ((mutt_autocrypt_db_account_get(from, &account) <= 0) || !account->enabled)
592  {
593  if (keylist)
594  {
595  /* L10N: Error displayed if the user tries to force sending an Autocrypt
596  email when the account does not exist or is not enabled.
597  %s is the From email address used to look up the Autocrypt account.
598  */
599  mutt_message(_("Autocrypt is not enabled for %s"), NONULL(from->mailbox));
600  }
601  goto cleanup;
602  }
603 
604  keylist_buf = mutt_buffer_pool_get();
605  mutt_buffer_addstr(keylist_buf, account->keyid);
606 
607  mutt_addrlist_copy(&recips, &e->env->to, false);
608  mutt_addrlist_copy(&recips, &e->env->cc, false);
609  mutt_addrlist_copy(&recips, &e->env->bcc, false);
610 
611  rc = AUTOCRYPT_REC_NO;
612  if (TAILQ_EMPTY(&recips))
613  goto cleanup;
614 
615  TAILQ_FOREACH(recip, &recips, entries)
616  {
617  if (mutt_autocrypt_db_peer_get(recip, &peer) <= 0)
618  {
619  if (keylist)
620  {
621  /* L10N: s is an email address. Autocrypt is scanning for the keyids
622  to use to encrypt, but it can't find a valid keyid for this address.
623  The message is printed and they are returned to the compose menu. */
624  mutt_message(_("No (valid) autocrypt key found for %s"), recip->mailbox);
625  }
626  goto cleanup;
627  }
628 
630  {
631  matching_key = peer->keyid;
632 
633  if (!(peer->last_seen && peer->autocrypt_timestamp) ||
634  (peer->last_seen - peer->autocrypt_timestamp > (35 * 24 * 60 * 60)))
635  {
636  has_discourage = true;
637  all_encrypt = false;
638  }
639 
640  if (!account->prefer_encrypt || !peer->prefer_encrypt)
641  all_encrypt = false;
642  }
644  {
645  matching_key = peer->gossip_keyid;
646 
647  has_discourage = true;
648  all_encrypt = false;
649  }
650  else
651  {
652  if (keylist)
653  mutt_message(_("No (valid) autocrypt key found for %s"), recip->mailbox);
654  goto cleanup;
655  }
656 
657  if (!mutt_buffer_is_empty(keylist_buf))
658  mutt_buffer_addch(keylist_buf, ' ');
659  mutt_buffer_addstr(keylist_buf, matching_key);
660 
662  }
663 
664  if (all_encrypt)
665  rc = AUTOCRYPT_REC_YES;
666  else if (has_discourage)
668  else
670 
671  if (keylist)
672  mutt_str_replace(keylist, mutt_buffer_string(keylist_buf));
673 
674 cleanup:
676  mutt_addrlist_clear(&recips);
678  mutt_buffer_pool_release(&keylist_buf);
679  return rc;
680 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
AutocryptRec
Recommendation.
Definition: lib.h:154
#define NONULL(x)
Definition: string2.h:37
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
#define TAILQ_FIRST(head)
Definition: queue.h:716
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
Definition: db.c:240
#define mutt_message(...)
Definition: logging.h:83
Autocrypt should be used.
Definition: lib.h:160
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1468
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:737
String manipulation buffer.
Definition: buffer.h:33
#define _(a)
Definition: message.h:28
An email address.
Definition: address.h:34
char * mailbox
Mailbox and host address.
Definition: address.h:37
No recommendations.
Definition: lib.h:156
char * keyid
Definition: lib.h:106
Do no use Autocrypt.
Definition: lib.h:157
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
sqlite3_int64 autocrypt_timestamp
Definition: lib.h:119
bool enabled
Definition: lib.h:109
Autocrypt peer.
Definition: lib.h:115
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
struct Envelope * env
Envelope information.
Definition: email.h:90
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
bool prefer_encrypt
false = nopref, true = mutual
Definition: lib.h:108
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:225
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:98
bool mutt_autocrypt_gpgme_is_valid_key(const char *keyid)
Is a key id valid?
Definition: gpgme.c:355
sqlite3_int64 last_seen
Definition: lib.h:118
char * gossip_keyid
Definition: lib.h:124
Prefer not to use Autocrypt.
Definition: lib.h:158
size_t mutt_buffer_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:240
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib...
Definition: email.h:39
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
Definition: db.c:259
bool prefer_encrypt
false = nopref, true = mutual
Definition: lib.h:122
Autocrypt account.
Definition: lib.h:103
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
void mutt_autocrypt_db_peer_free(struct AutocryptPeer **ptr)
Free an AutocryptPeer.
Definition: db.c:524
Autocrypt is available.
Definition: lib.h:159
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
#define TAILQ_NEXT(elm, field)
Definition: queue.h:825
#define TAILQ_EMPTY(head)
Definition: queue.h:714
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:630
char * keyid
Definition: lib.h:120
int mutt_autocrypt_db_peer_get(struct Address *addr, struct AutocryptPeer **peer)
Get peer info from the Autocrypt database.
Definition: db.c:546
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_write_autocrypt_header()

int mutt_autocrypt_write_autocrypt_header ( struct Envelope env,
FILE *  fp 
)

Write the Autocrypt header to a file.

Parameters
envEnvelope
fpFile to write to
Return values
0Success
-1Error

Definition at line 753 of file autocrypt.c.

754 {
755  int rc = -1;
756  struct AutocryptAccount *account = NULL;
757 
758  if (!C_Autocrypt || mutt_autocrypt_init(false) || !env)
759  return -1;
760 
761  struct Address *from = TAILQ_FIRST(&env->from);
762  if (!from || TAILQ_NEXT(from, entries))
763  return -1;
764 
765  if (mutt_autocrypt_db_account_get(from, &account) <= 0)
766  goto cleanup;
767  if (!account->keydata)
768  goto cleanup;
769  if (!account->enabled)
770  goto cleanup;
771 
772  fputs("Autocrypt: ", fp);
774  account->keydata);
775 
776  rc = 0;
777 
778 cleanup:
780  return rc;
781 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
#define TAILQ_FIRST(head)
Definition: queue.h:716
void mutt_autocrypt_db_account_free(struct AutocryptAccount **ptr)
Free an AutocryptAccount.
Definition: db.c:240
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
An email address.
Definition: address.h:34
char * email_addr
Definition: lib.h:105
bool enabled
Definition: lib.h:109
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
bool prefer_encrypt
false = nopref, true = mutual
Definition: lib.h:108
int mutt_autocrypt_db_account_get(struct Address *addr, struct AutocryptAccount **account)
Get Autocrypt Account data from the database.
Definition: db.c:259
Autocrypt account.
Definition: lib.h:103
static void write_autocrypt_header_line(FILE *fp, const char *addr, bool prefer_encrypt, const char *keydata)
Write an Autocrypt header to a file.
Definition: autocrypt.c:724
char * keydata
Definition: lib.h:107
#define TAILQ_NEXT(elm, field)
Definition: queue.h:825
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_autocrypt_write_gossip_headers()

int mutt_autocrypt_write_gossip_headers ( struct Envelope env,
FILE *  fp 
)

Write the Autocrypt gossip headers to a file.

Parameters
envEnvelope
fpFile to write to
Return values
0Success
-1Error

Definition at line 790 of file autocrypt.c.

791 {
792  if (!C_Autocrypt || mutt_autocrypt_init(false) || !env)
793  return -1;
794 
795  for (struct AutocryptHeader *gossip = env->autocrypt_gossip; gossip;
796  gossip = gossip->next)
797  {
798  fputs("Autocrypt-Gossip: ", fp);
799  write_autocrypt_header_line(fp, gossip->addr, 0, gossip->keydata);
800  }
801 
802  return 0;
803 }
int mutt_autocrypt_init(bool can_create)
Initialise Autocrypt.
Definition: autocrypt.c:93
struct AutocryptHeader * autocrypt_gossip
Definition: envelope.h:86
bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: config.c:37
struct AutocryptHeader * next
Definition: envelope.h:47
Parse Autocrypt header info.
Definition: envelope.h:41
static void write_autocrypt_header_line(FILE *fp, const char *addr, bool prefer_encrypt, const char *keydata)
Write an Autocrypt header to a file.
Definition: autocrypt.c:724
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ AutocryptSignAs

char* AutocryptSignAs

Autocrypt Key id to sign as.

Definition at line 42 of file config.c.

◆ AutocryptDefaultKey

char* AutocryptDefaultKey

Autocrypt default key id (used for postponing messages)

Definition at line 43 of file config.c.

◆ C_Autocrypt

bool C_Autocrypt

Config: Enables the Autocrypt feature.

Definition at line 37 of file config.c.

◆ C_AutocryptReply

bool C_AutocryptReply

Config: Replying to an autocrypt email automatically enables autocrypt in the reply.

Definition at line 38 of file config.c.

◆ C_AutocryptAcctFormat

char* C_AutocryptAcctFormat

Config: Format of the autocrypt account menu.

Definition at line 39 of file config.c.

◆ C_AutocryptDir

char* C_AutocryptDir

Config: Location of autocrypt files, including the GPG keyring and SQLite database.

Definition at line 40 of file config.c.