Skip to content

Commit

Permalink
scd: skip unsupported keys instead of failing
Browse files Browse the repository at this point in the history
  • Loading branch information
z9u2k authored and alonbl committed Nov 9, 2024
1 parent cee40f2 commit 9cbc61b
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions gnupg-pkcs11-scd/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ send_certificate_list (
}

if (error == GPG_ERR_WRONG_PUBKEY_ALGO) {
/* skip unsupported keys */
error = GPG_ERR_NO_ERROR;
}

Expand All @@ -544,8 +545,6 @@ int _get_certificate_by_name (assuan_context_t ctx, const char *name, int typehi
pkcs11h_certificate_id_list_t user_certificates = NULL;
pkcs11h_certificate_id_list_t curr_cert;
pkcs11h_certificate_id_t cert_id = NULL;
char *key_hexgrip = NULL;
gcry_sexp_t sexp = NULL;
const char *key = NULL;
int type;

Expand Down Expand Up @@ -617,14 +616,16 @@ int _get_certificate_by_name (assuan_context_t ctx, const char *name, int typehi
curr_cert != NULL && cert_id == NULL;
curr_cert = curr_cert->next
) {
gcry_sexp_t sexp = NULL;
char *key_hexgrip = NULL;

if ((error = get_cert_sexp (ctx, curr_cert->certificate_id, &sexp)) != GPG_ERR_NO_ERROR) {
goto cleanup;
goto retry;
}

if ((key_hexgrip = keyutil_get_cert_hexgrip (sexp)) == NULL) {
error = GPG_ERR_ENOMEM;
goto cleanup;
goto retry;
}

if (!strcmp (key_hexgrip, key)) {
Expand All @@ -636,9 +637,31 @@ int _get_certificate_by_name (assuan_context_t ctx, const char *name, int typehi
)
)) != GPG_ERR_NO_ERROR
) {
goto cleanup;
goto retry;
}
}

error = GPG_ERR_NO_ERROR;

retry:
if (sexp != NULL) {
gcry_sexp_release(sexp);
sexp = NULL;
}

if (key_hexgrip != NULL) {
free (key_hexgrip);
key_hexgrip = NULL;
}

if (error == GPG_ERR_WRONG_PUBKEY_ALGO) {
/* skip unsupported keys */
error = GPG_ERR_NO_ERROR;
}

if (error != GPG_ERR_NO_ERROR) {
goto cleanup;
}
}

if (cert_id == NULL) {
Expand All @@ -655,16 +678,6 @@ int _get_certificate_by_name (assuan_context_t ctx, const char *name, int typehi

cleanup:

if (sexp != NULL) {
gcry_sexp_release(sexp);
sexp = NULL;
}

if (key_hexgrip != NULL) {
free (key_hexgrip);
key_hexgrip = NULL;
}

if (user_certificates != NULL) {
pkcs11h_certificate_freeCertificateIdList (user_certificates);
user_certificates = NULL;
Expand Down Expand Up @@ -1777,6 +1790,11 @@ gpg_error_t cmd_keyinfo (assuan_context_t ctx, char *line)
key_hexgrip = NULL;
}

if (error == GPG_ERR_WRONG_PUBKEY_ALGO) {
/* skip unsupported keys */
error = GPG_ERR_NO_ERROR;
}

if (error != GPG_ERR_NO_ERROR) {
goto cleanup;
}
Expand Down

0 comments on commit 9cbc61b

Please sign in to comment.