NeoMutt  2022-04-29-323-g5fcc6c
Teaching an old dog new tricks
DOXYGEN
valid_passphrase()

Ensure we have a valid passphrase. More...

+ Collaboration diagram for valid_passphrase():

Functions

static bool pgp_gpgme_valid_passphrase (void)
 Implements CryptModuleSpecs::valid_passphrase() -. More...
 
static bool smime_gpgme_valid_passphrase (void)
 Implements CryptModuleSpecs::valid_passphrase() -. More...
 
bool pgp_class_valid_passphrase (void)
 Implements CryptModuleSpecs::valid_passphrase() -. More...
 
bool smime_class_valid_passphrase (void)
 Implements CryptModuleSpecs::valid_passphrase() -. More...
 

Detailed Description

Ensure we have a valid passphrase.

Return values
trueSuccess
falseFailed

If the passphrase is within the expiry time (backend-specific), use it. If not prompt the user again.

Function Documentation

◆ pgp_gpgme_valid_passphrase()

static bool pgp_gpgme_valid_passphrase ( void  )
static

Implements CryptModuleSpecs::valid_passphrase() -.

This is handled by gpg-agent.

Definition at line 50 of file crypt_mod_pgp_gpgme.c.

51{
52 return true;
53}

◆ smime_gpgme_valid_passphrase()

static bool smime_gpgme_valid_passphrase ( void  )
static

Implements CryptModuleSpecs::valid_passphrase() -.

This is handled by gpg-agent.

Definition at line 50 of file crypt_mod_smime_gpgme.c.

51{
52 return true;
53}

◆ pgp_class_valid_passphrase()

bool pgp_class_valid_passphrase ( void  )

Implements CryptModuleSpecs::valid_passphrase() -.

Definition at line 84 of file pgp.c.

85{
87 {
88 *PgpPass = '\0';
89 return true; /* handled by gpg-agent */
90 }
91
93 {
94 /* Use cached copy. */
95 return true;
96 }
97
99
100 struct Buffer *buf = mutt_buffer_pool_get();
101 const int rc = mutt_buffer_get_field(_("Enter PGP passphrase:"), buf,
103 false, NULL, NULL, NULL);
106
107 if (rc == 0)
108 {
109 const long c_pgp_timeout = cs_subset_long(NeoMutt->sub, "pgp_timeout");
111 return true;
112 }
113 else
114 {
115 PgpExptime = 0;
116 }
117
118 return false;
119}
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
long cs_subset_long(const struct ConfigSubset *sub, const char *name)
Get a long config item by name.
Definition: helpers.c:121
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:428
time_t mutt_date_add_timeout(time_t now, time_t timeout)
Safely add a timeout to a given time_t value.
Definition: date.c:637
int mutt_buffer_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
Definition: window.c:180
void pgp_class_void_passphrase(void)
Implements CryptModuleSpecs::void_passphrase() -.
Definition: pgp.c:75
#define _(a)
Definition: message.h:28
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:652
#define MUTT_COMP_PASS
Password mode (no echo)
Definition: mutt.h:63
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
Definition: mutt.h:64
char PgpPass[1024]
Definition: pgp.c:69
time_t PgpExptime
Definition: pgp.c:70
bool pgp_use_gpg_agent(void)
Does the user want to use the gpg agent?
Definition: pgp.c:127
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
String manipulation buffer.
Definition: buffer.h:34
Container for Accounts, Notifications.
Definition: neomutt.h:37
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smime_class_valid_passphrase()

bool smime_class_valid_passphrase ( void  )

Implements CryptModuleSpecs::valid_passphrase() -.

Definition at line 168 of file smime.c.

169{
170 const time_t now = mutt_date_epoch();
171 if (now < SmimeExpTime)
172 {
173 /* Use cached copy. */
174 return true;
175 }
176
178
179 struct Buffer *buf = mutt_buffer_pool_get();
180 const int rc = mutt_buffer_get_field(_("Enter S/MIME passphrase:"), buf,
182 false, NULL, NULL, NULL);
185
186 if (rc == 0)
187 {
188 const short c_smime_timeout = cs_subset_number(NeoMutt->sub, "smime_timeout");
189 SmimeExpTime = mutt_date_add_timeout(now, c_smime_timeout);
190 return true;
191 }
192 else
193 {
194 SmimeExpTime = 0;
195 }
196
197 return false;
198}
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition: helpers.c:169
void smime_class_void_passphrase(void)
Implements CryptModuleSpecs::void_passphrase() -.
Definition: smime.c:159
char SmimePass[256]
Definition: smime.c:78
time_t SmimeExpTime
Definition: smime.c:79
+ Here is the call graph for this function:
+ Here is the caller graph for this function: