NeoMutt  2025-12-11-769-g906513
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 81 of file pgp.c.

82{
85 {
86 *mod_data->pgp_pass = '\0';
87 return true; /* handled by gpg-agent */
88 }
89
90 if (mutt_date_now() < mod_data->pgp_exptime)
91 {
92 /* Use cached copy. */
93 return true;
94 }
95
97
98 struct Buffer *buf = buf_pool_get();
99 const int rc = mw_get_field(_("Enter PGP passphrase:"), buf,
101 mutt_str_copy(mod_data->pgp_pass, buf_string(buf), sizeof(mod_data->pgp_pass));
102 buf_pool_release(&buf);
103
104 if (rc == 0)
105 {
106 const long c_pgp_timeout = cs_subset_long(NeoMutt->sub, "pgp_timeout");
107 mod_data->pgp_exptime = mutt_date_add_timeout(mutt_date_now(), c_pgp_timeout);
108 return true;
109 }
110 else
111 {
112 mod_data->pgp_exptime = 0;
113 }
114
115 return false;
116}
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:71
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:467
@ HC_OTHER
Miscellaneous strings.
Definition lib.h:60
@ MODULE_ID_NCRYPT
ModuleNcrypt, Ncrypt
Definition module_api.h:80
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
void * neomutt_get_module_data(struct NeoMutt *n, enum ModuleId id)
Get the private data for a Module.
Definition neomutt.c:665
bool pgp_use_gpg_agent(void)
Does the user want to use the gpg agent?
Definition pgp.c:124
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
Ncrypt private Module data.
Definition module_data.h:38
char pgp_pass[1024]
Cached PGP Passphrase.
Definition module_data.h:50
time_t pgp_exptime
Unix time when pgp_pass expires.
Definition module_data.h:51
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 147 of file smime.c.

148{
150 const time_t now = mutt_date_now();
151 if (now < mod_data->smime_exp_time)
152 {
153 /* Use cached copy. */
154 return true;
155 }
156
158
159 struct Buffer *buf = buf_pool_get();
160 const int rc = mw_get_field(_("Enter S/MIME passphrase:"), buf,
162 mutt_str_copy(mod_data->smime_pass, buf_string(buf), sizeof(mod_data->smime_pass));
163 buf_pool_release(&buf);
164
165 if (rc == 0)
166 {
167 const short c_smime_timeout = cs_subset_number(NeoMutt->sub, "smime_timeout");
168 mod_data->smime_exp_time = mutt_date_add_timeout(now, c_smime_timeout);
169 return true;
170 }
171 else
172 {
173 mod_data->smime_exp_time = 0;
174 }
175
176 return false;
177}
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:137
char smime_pass[256]
Cached S/MIME Passphrase.
Definition module_data.h:55
time_t smime_exp_time
Unix time when smime_pass expires.
Definition module_data.h:56
+ Here is the call graph for this function:
+ Here is the caller graph for this function: