From 1908fa8b835cc46cb62afb8dcd26cdd0c93bc9fd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 12 Aug 2022 11:46:30 +0200 Subject: [PATCH] gpg: Improve --edit-key setpref. * g10/keygen.c (keygen_set_std_prefs): Allow extra spaces before preference elements. Detect the bracketed versions of the strings. Ignore "aead". -- This allows to c+p the list shown by pref with out remove the brackets. --- g10/keygen.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/g10/keygen.c b/g10/keygen.c index 945494a8b..7f3ed8ccb 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -487,7 +487,9 @@ keygen_set_std_prefs (const char *string,int personal) while((tok=strsep(&prefstring," ,"))) { - if((val=string_to_cipher_algo (tok))) + if (!*tok) + ; + else if((val=string_to_cipher_algo (tok))) { if(set_one_pref(val,1,tok,sym,&nsym)) rc=-1; @@ -507,14 +509,24 @@ keygen_set_std_prefs (const char *string,int personal) if (set_one_pref (val, 4, tok, aead, &naead)) rc = -1; } - else if (ascii_strcasecmp(tok,"mdc")==0) + else if (!ascii_strcasecmp(tok, "mdc") + || !ascii_strcasecmp(tok, "[mdc]")) mdc=1; - else if (ascii_strcasecmp(tok,"no-mdc")==0) + else if (!ascii_strcasecmp(tok, "no-mdc") + || !ascii_strcasecmp(tok, "[no-mdc]")) mdc=0; - else if (ascii_strcasecmp(tok,"ks-modify")==0) + else if (!ascii_strcasecmp(tok, "ks-modify") + || !ascii_strcasecmp(tok, "[ks-modify]")) modify=1; - else if (ascii_strcasecmp(tok,"no-ks-modify")==0) + else if (!ascii_strcasecmp(tok,"no-ks-modify") + || !ascii_strcasecmp(tok,"[no-ks-modify]")) modify=0; + else if (!ascii_strcasecmp(tok,"aead") + || !ascii_strcasecmp(tok,"[aead]")) + { + /* Ignore because this is set from the preferences but + * shown in the in the preferences/features list. */ + } else { log_info (_("invalid item '%s' in preference string\n"),tok);