scd: Report any error for LEARN command.

* scd/app-openpgp.c (do_learn_status): Report any error.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-09-30 10:48:49 +09:00
parent 1444203ca3
commit 862d9c6fac
1 changed files with 65 additions and 28 deletions

View File

@ -2101,40 +2101,77 @@ send_keypair_info (app_t app, ctrl_t ctrl, int key)
static gpg_error_t static gpg_error_t
do_learn_status (app_t app, ctrl_t ctrl, unsigned int flags) do_learn_status (app_t app, ctrl_t ctrl, unsigned int flags)
{ {
gpg_error_t err = 0;
(void)flags; (void)flags;
do_getattr (app, ctrl, "EXTCAP"); err = do_getattr (app, ctrl, "EXTCAP");
do_getattr (app, ctrl, "MANUFACTURER"); if (!err)
do_getattr (app, ctrl, "DISP-NAME"); err = do_getattr (app, ctrl, "MANUFACTURER");
do_getattr (app, ctrl, "DISP-LANG"); if (!err)
do_getattr (app, ctrl, "DISP-SEX"); err = do_getattr (app, ctrl, "DISP-NAME");
do_getattr (app, ctrl, "PUBKEY-URL"); if (!err)
do_getattr (app, ctrl, "LOGIN-DATA"); err = do_getattr (app, ctrl, "DISP-LANG");
do_getattr (app, ctrl, "KEY-FPR"); if (!err)
if (app->appversion > 0x0100) err = do_getattr (app, ctrl, "DISP-SEX");
do_getattr (app, ctrl, "KEY-TIME"); if (!err)
do_getattr (app, ctrl, "CA-FPR"); err = do_getattr (app, ctrl, "PUBKEY-URL");
do_getattr (app, ctrl, "CHV-STATUS"); if (!err)
do_getattr (app, ctrl, "SIG-COUNTER"); err = do_getattr (app, ctrl, "LOGIN-DATA");
if (app->app_local->extcap.kdf_do) if (!err)
do_getattr (app, ctrl, "KDF"); err = do_getattr (app, ctrl, "KEY-FPR");
if (app->app_local->extcap.has_button) if (!err && app->appversion > 0x0100)
do_getattr (app, ctrl, "UIF"); err = do_getattr (app, ctrl, "KEY-TIME");
if (app->app_local->extcap.private_dos) if (!err)
err = do_getattr (app, ctrl, "CA-FPR");
if (!err)
err = do_getattr (app, ctrl, "CHV-STATUS");
if (!err)
err = do_getattr (app, ctrl, "SIG-COUNTER");
if (!err && app->app_local->extcap.kdf_do)
{ {
do_getattr (app, ctrl, "PRIVATE-DO-1"); err = do_getattr (app, ctrl, "KDF");
do_getattr (app, ctrl, "PRIVATE-DO-2"); if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
if (app->did_chv2) err = 0;
do_getattr (app, ctrl, "PRIVATE-DO-3");
if (app->did_chv3)
do_getattr (app, ctrl, "PRIVATE-DO-4");
} }
send_keypair_info (app, ctrl, 1); if (!err && app->app_local->extcap.has_button)
send_keypair_info (app, ctrl, 2); err = do_getattr (app, ctrl, "UIF");
send_keypair_info (app, ctrl, 3); if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err && app->app_local->extcap.private_dos)
{
if (!err)
err = do_getattr (app, ctrl, "PRIVATE-DO-1");
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err)
err = do_getattr (app, ctrl, "PRIVATE-DO-2");
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err && app->did_chv2)
err = do_getattr (app, ctrl, "PRIVATE-DO-3");
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err && app->did_chv3)
err = do_getattr (app, ctrl, "PRIVATE-DO-4");
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
}
if (!err)
err = send_keypair_info (app, ctrl, 1);
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err)
err = send_keypair_info (app, ctrl, 2);
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
if (!err)
err = send_keypair_info (app, ctrl, 3);
if (gpg_err_code (err) == GPG_ERR_NO_OBJ)
err = 0;
/* Note: We do not send the Cardholder Certificate, because that is /* Note: We do not send the Cardholder Certificate, because that is
relatively long and for OpenPGP applications not really needed. */ relatively long and for OpenPGP applications not really needed. */
return 0; return err;
} }