gnutls-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gnutls branch, gnutls_3_0_x-2, updated. gnutls_3_0_20-16-ge8b7


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_3_0_x-2, updated. gnutls_3_0_20-16-ge8b7ba3
Date: Thu, 21 Jun 2012 18:59:54 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=e8b7ba366cdc6cdfaf769e5e45b8e0b9689f4a5e

The branch, gnutls_3_0_x-2 has been updated
       via  e8b7ba366cdc6cdfaf769e5e45b8e0b9689f4a5e (commit)
      from  96ad1b01fc2915f7966f166cb0d87cd9e82f271f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e8b7ba366cdc6cdfaf769e5e45b8e0b9689f4a5e
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Jun 21 20:57:38 2012 +0200

    Use the label when looking for a certificate or private key in PKCS #11.
    
    Patch by David Woodhouse.
    
    Conflicts:
    
        lib/pkcs11.c

-----------------------------------------------------------------------

Summary of changes:
 lib/pkcs11.c         |   31 +++++++++++++++++++++----------
 lib/pkcs11_privkey.c |    8 ++++++--
 2 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/lib/pkcs11.c b/lib/pkcs11.c
index 4897f62..056c68c 100644
--- a/lib/pkcs11.c
+++ b/lib/pkcs11.c
@@ -1415,6 +1415,7 @@ find_obj_url (struct ck_function_list *module, 
ck_session_handle_t pks,
   int found = 0, ret;
   uint8_t *cert_data = NULL;
   char label_tmp[PKCS11_LABEL_SIZE];
+  char id_tmp[PKCS11_ID_SIZE];
 
   if (info == NULL)
     {                           /* we don't support multiple calls */
@@ -1431,8 +1432,22 @@ find_obj_url (struct ck_function_list *module, 
ck_session_handle_t pks,
       return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
     }
 
+  a_vals = 0;
   attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_ID);
-  if (attr == NULL)
+  if (attr)
+    {
+      memcpy (a + a_vals, attr, sizeof (struct ck_attribute));
+      a_vals++;
+    }
+
+  attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_LABEL);
+  if (attr)
+    {
+      memcpy (a + a_vals, attr, sizeof (struct ck_attribute));
+      a_vals++;
+    }
+
+  if (!a_vals)
     {
       gnutls_assert ();
       return GNUTLS_E_INVALID_REQUEST;
@@ -1448,9 +1463,6 @@ find_obj_url (struct ck_function_list *module, 
ck_session_handle_t pks,
     }
 
   /* Find objects with given class and type */
-  memcpy (a, attr, sizeof (struct ck_attribute));
-  a_vals = 1;
-
   attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_CLASS);
   if (attr)
     {
@@ -1488,17 +1500,16 @@ find_obj_url (struct ck_function_list *module, 
ck_session_handle_t pks,
       a[1].type = CKA_LABEL;
       a[1].value = label_tmp;
       a[1].value_len = sizeof (label_tmp);
+      a[2].type = CKA_ID;
+      a[2].value = id_tmp;
+      a[2].value_len = sizeof(id_tmp);
 
-      if (pkcs11_get_attribute_value (module, pks, obj, a, 2) == CKR_OK)
+      if (pkcs11_get_attribute_value (module, pks, obj, a, 3) == CKR_OK)
         {
-          gnutls_datum_t id;
+          gnutls_datum_t id = { a[2].value, a[2].value_len };
           gnutls_datum_t data = { a[0].value, a[0].value_len };
           gnutls_datum_t label = { a[1].value, a[1].value_len };
 
-          attr = p11_kit_uri_get_attribute (find_data->crt->info, CKA_ID);
-          id.data = attr->value;
-          id.size = attr->value_len;
-
           if (class == CKO_PUBLIC_KEY)
             {
               ret =
diff --git a/lib/pkcs11_privkey.c b/lib/pkcs11_privkey.c
index afbd8e4..ccec17e 100644
--- a/lib/pkcs11_privkey.c
+++ b/lib/pkcs11_privkey.c
@@ -260,8 +260,12 @@ gnutls_pkcs11_privkey_import_url (gnutls_pkcs11_privkey_t 
pkey,
   attr = p11_kit_uri_get_attribute (pkey->info, CKA_ID);
   if (!attr || !attr->value_len)
     {
-      gnutls_assert ();
-      return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
+      attr = p11_kit_uri_get_attribute (pkey->info, CKA_LABEL);
+      if (!attr || !attr->value_len)
+        {
+          gnutls_assert ();
+          return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
+        }
     }
 
   FIND_OBJECT (module, pks, obj, pkey);


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]