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>
This commit is contained in:
Werner Koch 2021-03-19 18:28:00 +01:00
parent 37b1c5c200
commit 475644e049
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 20 additions and 6 deletions

View File

@ -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 */