mirror of
git://git.gnupg.org/gnupg.git
synced 2025-05-14 08:13:25 +02:00
common: Extend function pubkey_algo_string.
* common/sexputil.c (pubkey_algo_string): Add arg R_ALGOID. * sm/certreqgen-ui.c (gpgsm_gencertreq_tty): Adjust. Signed-off-by: Werner Koch <wk@gnupg.org> (cherry picked from commit f952226043824cbbeb8517126b5266926121c4e8) Removed the changes in gpg-card which is not part of 2.2 Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c185f6dfbd
commit
0353cb0a5e
@ -581,9 +581,9 @@ get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen)
|
|||||||
|
|
||||||
/* Given the public key S_PKEY, return a new buffer with a descriptive
|
/* Given the public key S_PKEY, return a new buffer with a descriptive
|
||||||
* string for its algorithm. This function may return NULL on memory
|
* string for its algorithm. This function may return NULL on memory
|
||||||
* error. */
|
* error. If R_ALGOID is not NULL the gcrypt algo id is stored there. */
|
||||||
char *
|
char *
|
||||||
pubkey_algo_string (gcry_sexp_t s_pkey)
|
pubkey_algo_string (gcry_sexp_t s_pkey, enum gcry_pk_algos *r_algoid)
|
||||||
{
|
{
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
gcry_sexp_t l1;
|
gcry_sexp_t l1;
|
||||||
@ -591,6 +591,9 @@ pubkey_algo_string (gcry_sexp_t s_pkey)
|
|||||||
int algo;
|
int algo;
|
||||||
char *result;
|
char *result;
|
||||||
|
|
||||||
|
if (r_algoid)
|
||||||
|
*r_algoid = 0;
|
||||||
|
|
||||||
l1 = gcry_sexp_find_token (s_pkey, "public-key", 0);
|
l1 = gcry_sexp_find_token (s_pkey, "public-key", 0);
|
||||||
if (!l1)
|
if (!l1)
|
||||||
return xtrystrdup ("E_no_key");
|
return xtrystrdup ("E_no_key");
|
||||||
@ -632,6 +635,8 @@ pubkey_algo_string (gcry_sexp_t s_pkey)
|
|||||||
else
|
else
|
||||||
result = xtryasprintf ("X_algo_%d", algo);
|
result = xtryasprintf ("X_algo_%d", algo);
|
||||||
|
|
||||||
|
if (r_algoid)
|
||||||
|
*r_algoid = algo;
|
||||||
xfree (algoname);
|
xfree (algoname);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ gpg_error_t get_rsa_pk_from_canon_sexp (const unsigned char *keydata,
|
|||||||
int get_pk_algo_from_key (gcry_sexp_t key);
|
int get_pk_algo_from_key (gcry_sexp_t key);
|
||||||
int get_pk_algo_from_canon_sexp (const unsigned char *keydata,
|
int get_pk_algo_from_canon_sexp (const unsigned char *keydata,
|
||||||
size_t keydatalen);
|
size_t keydatalen);
|
||||||
char *pubkey_algo_string (gcry_sexp_t s_pkey);
|
char *pubkey_algo_string (gcry_sexp_t s_pkey, enum gcry_pk_algos *r_algoid);
|
||||||
|
|
||||||
/*-- convert.c --*/
|
/*-- convert.c --*/
|
||||||
int hex2bin (const char *string, void *buffer, size_t length);
|
int hex2bin (const char *string, void *buffer, size_t length);
|
||||||
|
@ -257,7 +257,7 @@ gpgsm_gencertreq_tty (ctrl_t ctrl, estream_t output_stream)
|
|||||||
if (!gpgsm_agent_readkey (ctrl, 1, keyref, &pkey))
|
if (!gpgsm_agent_readkey (ctrl, 1, keyref, &pkey))
|
||||||
{
|
{
|
||||||
if (!gcry_sexp_new (&s_pkey, pkey, 0, 0))
|
if (!gcry_sexp_new (&s_pkey, pkey, 0, 0))
|
||||||
algostr = pubkey_algo_string (s_pkey);
|
algostr = pubkey_algo_string (s_pkey, NULL);
|
||||||
gcry_sexp_release (s_pkey);
|
gcry_sexp_release (s_pkey);
|
||||||
}
|
}
|
||||||
xfree (pkey);
|
xfree (pkey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user