aboutsummaryrefslogtreecommitdiffstats
path: root/g10/passphrase.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-05-17 17:27:54 +0000
committerWerner Koch <[email protected]>2021-05-17 17:48:15 +0000
commit6dfae2f402a702ccd7f2c585b28cb356e9f26a26 (patch)
tree199d5a9ebc0f1afdeb94a8e8e0096985b41d9770 /g10/passphrase.c
parentdirmngr: LDAP search by a mailbox now ignores revoked keys. (diff)
downloadgnupg-6dfae2f402a702ccd7f2c585b28cb356e9f26a26.tar.gz
gnupg-6dfae2f402a702ccd7f2c585b28cb356e9f26a26.zip
gpg: Use a more descriptive prompt for symmetric decryption.
* g10/keydb.h (GETPASSWORD_FLAG_SYMDECRYPT): New. (passphrase_to_dek_ext): Remove this obsolete prototype. * g10/passphrase.c (passphrase_get): Add arg flags. Use new flag value. (passphrase_to_dek): Add arg flags and pass it on. * g10/mainproc.c (proc_symkey_enc): Use new flag. * sm/decrypt.c (pwri_decrypt): Use "passphrase". -- Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 03f83bcda5d1f8d8246bcc1afc603b7f74d0626b) Note that we keep on using the term "passphrase" although "password" would be better. There are however so many occurance of this and given it is a bike shedding topic we fix that in the PO files. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/passphrase.c')
-rw-r--r--g10/passphrase.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 50bb0e18d..1793efc9d 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -171,15 +171,18 @@ read_passphrase_from_fd( int fd )
* operation. If CACHEID is not NULL, it will be used as the cacheID
* for the gpg-agent; if is NULL and a key fingerprint can be
* computed, this will be used as the cacheid.
+ *
+ * For FLAGS see passphrase_to_dek;
*/
static char *
passphrase_get (int newsymkey, int nocache, const char *cacheid, int repeat,
- const char *tryagain_text, int *canceled)
+ const char *tryagain_text, unsigned int flags, int *canceled)
{
int rc;
char *pw = NULL;
char *orig_codeset;
const char *my_cacheid;
+ const char *desc;
if (canceled)
*canceled = 0;
@@ -194,6 +197,11 @@ passphrase_get (int newsymkey, int nocache, const char *cacheid, int repeat,
if (tryagain_text)
tryagain_text = _(tryagain_text);
+ if ((flags & GETPASSWORD_FLAG_SYMDECRYPT))
+ desc = _("Please enter the passphrase for decryption.");
+ else
+ desc = _("Enter passphrase\n");
+
/* Here we have:
* REPEAT is set in create mode and if opt.passphrase_repeat is set.
* (Thus it is not a clean indication that we want a new passphrase).
@@ -205,7 +213,7 @@ passphrase_get (int newsymkey, int nocache, const char *cacheid, int repeat,
* for a full state analysis and thus this new parameter.
*/
rc = agent_get_passphrase (my_cacheid, tryagain_text, NULL,
- _("Enter passphrase\n"),
+ desc,
newsymkey, repeat, nocache, &pw);
i18n_switchback (orig_codeset);
@@ -264,11 +272,15 @@ passphrase_clear_cache (const char *cacheid)
* CANCELED is not NULL, sets it to true.
*
* If CREATE is true a new passphrase will be created. If NOCACHE is
- * true the symmetric key caching will not be used. */
+ * true the symmetric key caching will not be used.
+ * FLAG bits are:
+ * GETPASSWORD_FLAG_SYMDECRYPT := for symmetric decryption
+ */
DEK *
passphrase_to_dek (int cipher_algo, STRING2KEY *s2k,
int create, int nocache,
- const char *tryagain_text, int *canceled)
+ const char *tryagain_text, unsigned int flags,
+ int *canceled)
{
char *pw = NULL;
DEK *dek;
@@ -355,7 +367,7 @@ passphrase_to_dek (int cipher_algo, STRING2KEY *s2k,
/* Divert to the gpg-agent. */
pw = passphrase_get (create, create && nocache, s2k_cacheid,
create? opt.passphrase_repeat : 0,
- tryagain_text, canceled);
+ tryagain_text, flags, canceled);
if (*canceled)
{
xfree (pw);