NeoMutt  2025-12-11-694-ga89709
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
valid_passphrase()

Ensure we have a valid passphrase. More...

+ Collaboration diagram for valid_passphrase():

Functions

static bool pgp_gpgme_valid_passphrase (void)
 Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.
 
static bool smime_gpgme_valid_passphrase (void)
 Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.
 
bool pgp_class_valid_passphrase (void)
 Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.
 
bool smime_class_valid_passphrase (void)
 Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.
 

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

Ensure we have a valid passphrase - 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

Ensure we have a valid passphrase - 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 )

Ensure we have a valid passphrase - 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 = buf_pool_get();
101 const int rc = mw_get_field(_("Enter PGP passphrase:"), buf,
103 mutt_str_copy(PgpPass, buf_string(buf), sizeof(PgpPass));
104 buf_pool_release(&buf);
105
106 if (rc == 0)
107 {
108 const long c_pgp_timeout = cs_subset_long(NeoMutt->sub, "pgp_timeout");
110 return true;
111 }
112 else
113 {
114 PgpExptime = 0;
115 }
116
117 return false;
118}
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition buffer.h:96
long cs_subset_long(const struct ConfigSubset *sub, const char *name)
Get a long config item by name.
Definition helpers.c:95
#define MUTT_COMP_PASS
Password mode (no echo)
Definition wdata.h:44
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
Definition wdata.h:45
void pgp_class_void_passphrase(void)
Forget the cached passphrase - Implements CryptModuleSpecs::void_passphrase() -.
Definition pgp.c:75
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
Definition window.c:463
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
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:891
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Definition date.c:457
#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:586
static char PgpPass[1024]
Cached PGP Passphrase.
Definition pgp.c:68
static time_t PgpExptime
Unix time when PgpPass expires.
Definition pgp.c:70
bool pgp_use_gpg_agent(void)
Does the user want to use the gpg agent?
Definition pgp.c:126
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition pool.c:91
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition pool.c:111
String manipulation buffer.
Definition buffer.h:36
Container for Accounts, Notifications.
Definition neomutt.h:41
struct ConfigSubset * sub
Inherited config items.
Definition neomutt.h:49
+ 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 )

Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.

Definition at line 155 of file smime.c.

156{
157 const time_t now = mutt_date_now();
158 if (now < SmimeExpTime)
159 {
160 /* Use cached copy. */
161 return true;
162 }
163
165
166 struct Buffer *buf = buf_pool_get();
167 const int rc = mw_get_field(_("Enter S/MIME passphrase:"), buf,
170 buf_pool_release(&buf);
171
172 if (rc == 0)
173 {
174 const short c_smime_timeout = cs_subset_number(NeoMutt->sub, "smime_timeout");
175 SmimeExpTime = mutt_date_add_timeout(now, c_smime_timeout);
176 return true;
177 }
178 else
179 {
180 SmimeExpTime = 0;
181 }
182
183 return false;
184}
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
Definition helpers.c:143
void smime_class_void_passphrase(void)
Forget the cached passphrase - Implements CryptModuleSpecs::void_passphrase() -.
Definition smime.c:146
static char SmimePass[256]
Cached Smime Passphrase.
Definition smime.c:65
static time_t SmimeExpTime
Unix time when SmimePass expires.
Definition smime.c:67
+ Here is the call graph for this function:
+ Here is the caller graph for this function: