summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-03-19 18:28:00 +0100
committerWerner Koch <wk@gnupg.org>2021-03-19 18:28:00 +0100
commit475644e049436c49de7620a1539515479ad2aa4f (patch)
tree5f5577fc20ac5d9f77a3babc5c0fab2d88c0dddd /tools
parentscd:openpgp: Allow reading and writing user certs for keys 1 and 2 (diff)
downloadgnupg2-475644e049436c49de7620a1539515479ad2aa4f.tar.xz
gnupg2-475644e049436c49de7620a1539515479ad2aa4f.zip
card: Support OpenPGP.1 and OpenPGP.2 for readcert and writecert.
* tools/gpg-card.c (cmd_writecert): Allow the other key references. (cmd_readcert): Ditto. -- See previous commit for testing info. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/gpg-card.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index 9257bc78f..0b6acc27d 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -1970,13 +1970,20 @@ cmd_writecert (card_info_t info, char *argstr)
if (info->apptype == APP_TYPE_OPENPGP)
{
- if (ascii_strcasecmp (certref, "OPENPGP.3") && strcmp (certref, "3"))
+ if (!ascii_strcasecmp (certref, "OPENPGP.3") || !strcmp (certref, "3"))
+ certref_buffer = xstrdup ("OPENPGP.3");
+ else if (!ascii_strcasecmp (certref, "OPENPGP.2")||!strcmp (certref,"2"))
+ certref_buffer = xstrdup ("OPENPGP.2");
+ else if (!ascii_strcasecmp (certref, "OPENPGP.1")||!strcmp (certref,"1"))
+ certref_buffer = xstrdup ("OPENPGP.1");
+ else
{
err = gpg_error (GPG_ERR_INV_ID);
- log_error ("Error: CERTREF must be \"3\" or \"OPENPGP.3\"\n");
+ log_error ("Error: CERTREF must be OPENPGP.N or just N"
+ " with N being 1..3\"");
goto leave;
}
- certref = certref_buffer = xstrdup ("OPENPGP.3");
+ certref = certref_buffer;
}
else /* Upcase the certref; prepend cardtype if needed. */
{
@@ -2108,13 +2115,20 @@ cmd_readcert (card_info_t info, char *argstr)
if (info->apptype == APP_TYPE_OPENPGP)
{
- if (ascii_strcasecmp (certref, "OPENPGP.3") && strcmp (certref, "3"))
+ if (!ascii_strcasecmp (certref, "OPENPGP.3") || !strcmp (certref, "3"))
+ certref_buffer = xstrdup ("OPENPGP.3");
+ else if (!ascii_strcasecmp (certref, "OPENPGP.2")||!strcmp (certref,"2"))
+ certref_buffer = xstrdup ("OPENPGP.2");
+ else if (!ascii_strcasecmp (certref, "OPENPGP.1")||!strcmp (certref,"1"))
+ certref_buffer = xstrdup ("OPENPGP.1");
+ else
{
err = gpg_error (GPG_ERR_INV_ID);
- log_error ("Error: CERTREF must be \"3\" or \"OPENPGP.3\"\n");
+ log_error ("Error: CERTREF must be OPENPGP.N or just N"
+ " with N being 1..3\"");
goto leave;
}
- certref = certref_buffer = xstrdup ("OPENPGP.3");
+ certref = certref_buffer;
}
if (*argstr == '>') /* Write it to a file */