NeoMutt  2023-05-17-33-gce4425
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 85 of file pgp.c.

86{
88 {
89 *PgpPass = '\0';
90 return true; /* handled by gpg-agent */
91 }
92
94 {
95 /* Use cached copy. */
96 return true;
97 }
98
100
101 struct Buffer *buf = buf_pool_get();
102 const int rc = buf_get_field(_("Enter PGP passphrase:"), buf,
104 NULL, NULL, NULL);
105 mutt_str_copy(PgpPass, buf_string(buf), sizeof(PgpPass));
106 buf_pool_release(&buf);
107
108 if (rc == 0)
109 {
110 const long c_pgp_timeout = cs_subset_long(NeoMutt->sub, "pgp_timeout");
112 return true;
113 }
114 else
115 {
116 PgpExptime = 0;
117 }
118
119 return false;
120}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:78
long cs_subset_long(const struct ConfigSubset *sub, const char *name)
Get a long config item by name.
Definition: helpers.c:121
int buf_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:76
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:863
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:446
#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:653
#define MUTT_COMP_PASS
Password mode (no echo)
Definition: mutt.h:66
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
Definition: mutt.h:67
static char PgpPass[1024]
Cached PGP Passphrase.
Definition: pgp.c:69
static time_t PgpExptime
Unix time when PgpPass expires.
Definition: pgp.c:71
bool pgp_use_gpg_agent(void)
Does the user want to use the gpg agent?
Definition: pgp.c:128
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:106
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:119
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 173 of file smime.c.

174{
175 const time_t now = mutt_date_now();
176 if (now < SmimeExpTime)
177 {
178 /* Use cached copy. */
179 return true;
180 }
181
183
184 struct Buffer *buf = buf_pool_get();
185 const int rc = buf_get_field(_("Enter S/MIME passphrase:"), buf,
187 NULL, NULL, NULL);
189 buf_pool_release(&buf);
190
191 if (rc == 0)
192 {
193 const short c_smime_timeout = cs_subset_number(NeoMutt->sub, "smime_timeout");
194 SmimeExpTime = mutt_date_add_timeout(now, c_smime_timeout);
195 return true;
196 }
197 else
198 {
199 SmimeExpTime = 0;
200 }
201
202 return false;
203}
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:164
static char SmimePass[256]
Cached Smime Passphrase.
Definition: smime.c:79
static time_t SmimeExpTime
Unix time when SmimePass expires.
Definition: smime.c:81
+ Here is the call graph for this function:
+ Here is the caller graph for this function: