[Pkg-gnupg-commit] [gnupg2] 88/180: gpg: Do not use a fixed string for --gpgconf-list:default_pubkey_algo.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Sat Dec 24 22:29:12 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit f1304ee9b21e6ceac6c13d04ceddd23fadb5c7f1
Author: Werner Koch <wk at gnupg.org>
Date: Mon Dec 12 10:50:21 2016 +0100
gpg: Do not use a fixed string for --gpgconf-list:default_pubkey_algo.
* g10/keygen.c (get_default_pubkey_algo): New.
(parse_key_parameter_string): Use it.
* g10/gpg.c (gpgconf_list): Take value from new function.
--
Note that consumers of that gpgconf-list value may need to be adjusted
to that new value. It should anyway only be used to display the
default algorithm.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
g10/gpg.c | 2 +-
g10/keygen.c | 19 ++++++++++++++++++-
g10/main.h | 1 +
3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/g10/gpg.c b/g10/gpg.c
index ddb7715..c087387 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -1832,7 +1832,7 @@ gpgconf_list (const char *configfile)
/* The next one is an info only item and should match the macros at
the top of keygen.c */
es_printf ("default_pubkey_algo:%lu:\"%s:\n", GC_OPT_FLAG_DEFAULT,
- "RSA-2048");
+ get_default_pubkey_algo ());
xfree (configfile_esc);
}
diff --git a/g10/keygen.c b/g10/keygen.c
index 80ad0ba..c1abc70 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -152,6 +152,23 @@ static unsigned int get_keysize_range (int algo,
+/* Return the algo string for a default new key. */
+const char *
+get_default_pubkey_algo (void)
+{
+ if (opt.def_new_key_algo)
+ {
+ if (*opt.def_new_key_algo && !strchr (opt.def_new_key_algo, ':'))
+ return opt.def_new_key_algo;
+ /* To avoid checking that option every time we delay that until
+ * here. The only thing we really need to make sure is that
+ * there is no colon in the string so that the --gpgconf-list
+ * command won't mess up its output. */
+ log_info (_("invalid value for option '%s'\n"), "--default-new-key-algo");
+ }
+ return DEFAULT_STD_KEY_PARAM;
+}
+
static void
print_status_key_created (int letter, PKT_public_key *pk, const char *handle)
@@ -3122,7 +3139,7 @@ parse_key_parameter_string (const char *string, int part,
if (!string || !*string
|| !strcmp (string, "default") || !strcmp (string, "-"))
- string = opt.def_new_key_algo? opt.def_new_key_algo : DEFAULT_STD_KEY_PARAM;
+ string = get_default_pubkey_algo ();
else if (!strcmp (string, "future-default"))
string = FUTURE_STD_KEY_PARAM;
diff --git a/g10/main.h b/g10/main.h
index 1822ee4..5ed501b 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -300,6 +300,7 @@ void keyedit_quick_set_expire (ctrl_t ctrl,
void show_basic_key_info (KBNODE keyblock);
/*-- keygen.c --*/
+const char *get_default_pubkey_algo (void);
u32 parse_expire_string(const char *string);
u32 ask_expire_interval(int object,const char *def_expire);
u32 ask_expiredate(void);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list