From: Nikos Mavrogiannopoulos Date: Fri, 11 Apr 2008 23:15:58 +0000 (+0300) Subject: Added a flag in get_auth_subkey() to work for all use cases X-Git-Tag: gnutls_2_3_5~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e6c8228bf5dc250c81fb423940d5beffe1befd6;p=thirdparty%2Fgnutls.git Added a flag in get_auth_subkey() to work for all use cases --- diff --git a/lib/gnutls_openpgp.c b/lib/gnutls_openpgp.c index 76a8be0680..16e1d0c83d 100644 --- a/lib/gnutls_openpgp.c +++ b/lib/gnutls_openpgp.c @@ -399,7 +399,7 @@ gnutls_certificate_set_openpgp_key_mem2 (gnutls_certificate_credentials_t gnutls_openpgp_keyid_t keyid; if (strcasecmp( subkey_id, "auto")==0) - ret = gnutls_openpgp_crt_get_auth_subkey( cert, keyid); + ret = gnutls_openpgp_crt_get_auth_subkey( cert, keyid, 1); else ret = get_keyid( keyid, subkey_id); diff --git a/lib/openpgp/pgp.c b/lib/openpgp/pgp.c index 6ab31c1fa1..8397676a08 100644 --- a/lib/openpgp/pgp.c +++ b/lib/openpgp/pgp.c @@ -1471,12 +1471,14 @@ int ret; * gnutls_openpgp_crt_get_auth_subkey - Gets the keyID of an authentication subkey * @key: the structure that contains the OpenPGP public key. * @keyid: the struct to save the keyid. + * @flag: Non zero indicates that a valid subkey is always returned. * * Returns the 64-bit keyID of the first valid OpenPGP subkey marked for authentication. + * If flag is non zero then a valid subkey will be returned even if it is not marked for authentication. * * Returns zero on success. **/ -int gnutls_openpgp_crt_get_auth_subkey( gnutls_openpgp_crt_t crt, gnutls_openpgp_keyid_t keyid) +int gnutls_openpgp_crt_get_auth_subkey( gnutls_openpgp_crt_t crt, gnutls_openpgp_keyid_t keyid, unsigned int flag) { int ret, subkeys, i; unsigned int usage; @@ -1527,9 +1529,10 @@ int gnutls_openpgp_crt_get_auth_subkey( gnutls_openpgp_crt_t crt, gnutls_openpgp return ret; } - break; + return 0;;\ } } - return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; + if (flag && keyid_init) return 0; + else return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE; }