1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-05 23:07:49 +02:00

gpg: Cleanup of dek_to_passphrase function (part 1).

* g10/passphrase.c (passphrase_to_dek_ext): Remove args CUSTDESC and
CUSTPROMPT.  Merge into the passphrase_to_dek wrapper.
(passphrase_get): Remove args CUSTOM_DESCRIPTION and CUSTOM_PROMPT.
--

The function is nowadays only used for symmetric encryption.  Thus we
do not need all the former advanced stuff.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2016-08-08 17:42:37 +02:00
parent 591a8373a5
commit 5b614973fe
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -218,10 +218,8 @@ read_passphrase_from_fd( int fd )
* computed, this will be used as the cacheid. * computed, this will be used as the cacheid.
*/ */
static char * static char *
passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat, passphrase_get (u32 *keyid, int mode, const char *cacheid, int repeat,
const char *tryagain_text, const char *tryagain_text, int *canceled)
const char *custom_description,
const char *custom_prompt, int *canceled)
{ {
int rc; int rc;
char *atext = NULL; char *atext = NULL;
@ -230,7 +228,6 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
byte fpr[MAX_FINGERPRINT_LEN]; byte fpr[MAX_FINGERPRINT_LEN];
int have_fpr = 0; int have_fpr = 0;
char *orig_codeset; char *orig_codeset;
char *my_prompt;
char hexfprbuf[20*2+1]; char hexfprbuf[20*2+1];
const char *my_cacheid; const char *my_cacheid;
int check = (mode == 1); int check = (mode == 1);
@ -251,9 +248,7 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
orig_codeset = i18n_switchto_utf8 (); orig_codeset = i18n_switchto_utf8 ();
if (custom_description) if ( !mode && pk && keyid )
atext = native_to_utf8 (custom_description);
else if ( !mode && pk && keyid )
{ {
char *uid; char *uid;
size_t uidlen; size_t uidlen;
@ -306,12 +301,8 @@ passphrase_get ( u32 *keyid, int mode, const char *cacheid, int repeat,
if (tryagain_text) if (tryagain_text)
tryagain_text = _(tryagain_text); tryagain_text = _(tryagain_text);
my_prompt = custom_prompt ? native_to_utf8 (custom_prompt): NULL; rc = agent_get_passphrase (my_cacheid, tryagain_text, NULL, atext,
rc = agent_get_passphrase (my_cacheid, tryagain_text, my_prompt, atext,
repeat, check, &pw); repeat, check, &pw);
xfree (my_prompt);
xfree (atext); atext = NULL; xfree (atext); atext = NULL;
i18n_switchback (orig_codeset); i18n_switchback (orig_codeset);
@ -406,17 +397,17 @@ passphrase_clear_cache ( u32 *keyid, const char *cacheid, int algo )
4: Ditto, but create a new key 4: Ditto, but create a new key
*/ */
DEK * DEK *
passphrase_to_dek_ext (u32 *keyid, int pubkey_algo, passphrase_to_dek (u32 *keyid, int pubkey_algo,
int cipher_algo, STRING2KEY *s2k, int mode, int cipher_algo, STRING2KEY *s2k, int mode,
const char *tryagain_text, const char *tryagain_text,
const char *custdesc, const char *custprompt, int *canceled)
int *canceled)
{ {
char *pw = NULL; char *pw = NULL;
DEK *dek; DEK *dek;
STRING2KEY help_s2k; STRING2KEY help_s2k;
int dummy_canceled; int dummy_canceled;
char s2k_cacheidbuf[1+16+1], *s2k_cacheid = NULL; char s2k_cacheidbuf[1+16+1];
char *s2k_cacheid = NULL;
if (!canceled) if (!canceled)
canceled = &dummy_canceled; canceled = &dummy_canceled;
@ -543,7 +534,7 @@ passphrase_to_dek_ext (u32 *keyid, int pubkey_algo,
/* Divert to the gpg-agent. */ /* Divert to the gpg-agent. */
pw = passphrase_get (keyid, mode == 2, s2k_cacheid, pw = passphrase_get (keyid, mode == 2, s2k_cacheid,
(mode == 2 || mode == 4)? opt.passphrase_repeat : 0, (mode == 2 || mode == 4)? opt.passphrase_repeat : 0,
tryagain_text, custdesc, custprompt, canceled); tryagain_text, canceled);
if (*canceled) if (*canceled)
{ {
xfree (pw); xfree (pw);
@ -593,17 +584,6 @@ passphrase_to_dek_ext (u32 *keyid, int pubkey_algo,
} }
DEK *
passphrase_to_dek (u32 *keyid, int pubkey_algo,
int cipher_algo, STRING2KEY *s2k, int mode,
const char *tryagain_text, int *canceled)
{
return passphrase_to_dek_ext (keyid, pubkey_algo, cipher_algo,
s2k, mode, tryagain_text, NULL, NULL,
canceled);
}
/* Emit the USERID_HINT and the NEED_PASSPHRASE status messages. /* Emit the USERID_HINT and the NEED_PASSPHRASE status messages.
MAINKEYID may be NULL. */ MAINKEYID may be NULL. */
void void