From: Nikos Mavrogiannopoulos Date: Wed, 16 Mar 2011 18:08:18 +0000 (+0100) Subject: Read the public key algorithm from the selected subkey and not the master key when... X-Git-Tag: gnutls_2_99_0~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bdb4e7ee24ebb85b9cc562ee73ef88b2ffc73d4a;p=thirdparty%2Fgnutls.git Read the public key algorithm from the selected subkey and not the master key when importing to a gnutls_privkey. --- diff --git a/lib/gnutls_privkey.c b/lib/gnutls_privkey.c index 0ee2d9478a..87c99880d7 100644 --- a/lib/gnutls_privkey.c +++ b/lib/gnutls_privkey.c @@ -385,7 +385,8 @@ gnutls_privkey_import_openpgp (gnutls_privkey_t pkey, gnutls_openpgp_privkey_t key, unsigned int flags) { -int ret; +int ret, idx; +gnutls_openpgp_keyid_t keyid; ret = check_if_clean(pkey); if (ret < 0) @@ -396,7 +397,14 @@ int ret; pkey->key.openpgp = key; pkey->type = GNUTLS_PRIVKEY_OPENPGP; - pkey->pk_algorithm = gnutls_openpgp_privkey_get_pk_algorithm (key, NULL); + + ret = gnutls_openpgp_privkey_get_preferred_key_id (key, keyid); + if (ret < 0) + return gnutls_assert_val(ret); + + idx = gnutls_openpgp_privkey_get_subkey_idx (key, keyid); + + pkey->pk_algorithm = gnutls_openpgp_privkey_get_subkey_pk_algorithm (key, idx, NULL); pkey->flags = flags; return 0;