]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added a flag in get_auth_subkey() to work for all use cases
authorNikos Mavrogiannopoulos <nmav@crystal.(none)>
Fri, 11 Apr 2008 23:15:58 +0000 (02:15 +0300)
committerNikos Mavrogiannopoulos <nmav@crystal.(none)>
Fri, 11 Apr 2008 23:15:58 +0000 (02:15 +0300)
lib/gnutls_openpgp.c
lib/openpgp/pgp.c

index 76a8be06809accb5700749c6ae3ef62e4ff82e76..16e1d0c83d6d90dc84459b784fd5977b9ccf8f30 100644 (file)
@@ -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);
 
index 6ab31c1fa10441b7ae84bf0573b003d6d08525b0..8397676a084d5bb41ab686af2bc92f316c8d8be3 100644 (file)
@@ -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;
 }