1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

scd: Extend an internal function to also return the algo.

* scd/app-help.c (app_help_get_keygrip_string_pk): Add optional arg
r_algo.  Change all callers.
(app_help_get_keygrip_string): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-05-05 08:07:11 +02:00
parent 91dd74f3d7
commit 72a7d45a23
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
5 changed files with 19 additions and 12 deletions

View file

@ -54,12 +54,13 @@ app_help_count_bits (const unsigned char *a, size_t len)
/* Return the KEYGRIP for the canonical encoded public key (PK,PKLEN)
* as an hex encoded string in the user provided buffer HEXKEYGRIP
* which must be of at least 41 bytes. If R_PKEY is not NULL and the
* function succeeded, the S-expression representing the key is
* stored there. The caller needs to call gcry_sexp_release on
* that. */
* function succeeded, the S-expression representing the key is stored
* there. The caller needs to call gcry_sexp_release on that. If
* R_ALGO is not NULL the public key algorithm id of Libgcrypt is
* stored there. */
gpg_error_t
app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
gcry_sexp_t *r_pkey)
gcry_sexp_t *r_pkey, int *r_algo)
{
gpg_error_t err;
gcry_sexp_t s_pkey;
@ -77,6 +78,9 @@ app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
return gpg_error (GPG_ERR_GENERAL); /* Failed to calculate the keygrip.*/
}
if (r_algo)
*r_algo = get_pk_algo_from_key (s_pkey);
if (r_pkey)
*r_pkey = s_pkey;
else
@ -92,10 +96,11 @@ app_help_get_keygrip_string_pk (const void *pk, size_t pklen, char *hexkeygrip,
* string in the user provided buffer HEXKEYGRIP which must be of at
* least 41 bytes. If R_PKEY is not NULL and the function succeeded,
* the S-expression representing the key is stored there. The caller
* needs to call gcry_sexp_release on that. */
* needs to call gcry_sexp_release on that. If R_ALGO is not NULL the
* public key algorithm id of Libgcrypt is stored there. */
gpg_error_t
app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip,
gcry_sexp_t *r_pkey)
gcry_sexp_t *r_pkey, int *r_algo)
{
gpg_error_t err;
ksba_sexp_t p;
@ -110,7 +115,8 @@ app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip,
n = gcry_sexp_canon_len (p, 0, NULL, NULL);
if (!n)
return gpg_error (GPG_ERR_INV_SEXP);
err = app_help_get_keygrip_string_pk ((void*)p, n, hexkeygrip, r_pkey);
err = app_help_get_keygrip_string_pk ((void*)p, n, hexkeygrip,
r_pkey, r_algo);
ksba_free (p);
return err;
}