gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_4-13-g39783


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_4-13-g397837a
Date: Tue, 10 May 2011 13:14:20 +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=397837a760df01427d90b39dc10a08577f89e1b7

The branch, gnutls_2_12_x has been updated
       via  397837a760df01427d90b39dc10a08577f89e1b7 (commit)
       via  8bd438e27121034e36c0087ba0dfb28294c02f8a (commit)
      from  9f48fc146f588590f0a6222c9e87f1294ec77ab0 (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 397837a760df01427d90b39dc10a08577f89e1b7
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue May 10 15:14:15 2011 +0200

    updated

commit 8bd438e27121034e36c0087ba0dfb28294c02f8a
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue May 10 12:19:09 2011 +0200

    Correctly import and export pkcs11-urls with ID field set.

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

Summary of changes:
 NEWS             |    3 ++
 lib/gnutls_str.c |   11 +++++----
 lib/gnutls_str.h |    2 +-
 lib/pkcs11.c     |   67 +++++++++++++++++++++++------------------------------
 4 files changed, 39 insertions(+), 44 deletions(-)

diff --git a/NEWS b/NEWS
index c42bd5e..7652f68 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ See the end for copying conditions.
 ** certtool: Can now load private keys and public keys from PKCS #11 tokens
 via URLs.
 
+** libgnutls: PKCS #11 URLs conform to the latest draft
+being http://tools.ietf.org/html/draft-pechanec-pkcs11uri-04.
+
 ** libgnutls: gnutls_pkcs11_privkey_import_url() will now correctly read
 the public key algorithm of the key.
 
diff --git a/lib/gnutls_str.c b/lib/gnutls_str.c
index abdc733..d789d32 100644
--- a/lib/gnutls_str.c
+++ b/lib/gnutls_str.c
@@ -344,7 +344,7 @@ _gnutls_buffer_delete_data (gnutls_buffer_st * dest, int 
pos, size_t str_size)
 
 
 int
-_gnutls_buffer_escape (gnutls_buffer_st * dest,
+_gnutls_buffer_escape (gnutls_buffer_st * dest, int all,
                        const char *const invalid_chars)
 {
   int rv = -1;
@@ -354,8 +354,8 @@ _gnutls_buffer_escape (gnutls_buffer_st * dest,
   while (pos < dest->length)
     {
 
-      if (dest->data[pos] == '\\' || strchr (invalid_chars, dest->data[pos])
-          || !isgraph (dest->data[pos]))
+      if (all != 0 || (dest->data[pos] == '\\' || strchr (invalid_chars, 
dest->data[pos])
+          || !c_isgraph (dest->data[pos])))
         {
 
           snprintf (t, sizeof (t), "%%%.2X", (unsigned int) dest->data[pos]);
@@ -367,9 +367,10 @@ _gnutls_buffer_escape (gnutls_buffer_st * dest,
               rv = -1;
               goto cleanup;
             }
-
+          pos+=3;
         }
-      pos++;
+      else
+        pos++;
     }
 
   rv = 0;
diff --git a/lib/gnutls_str.h b/lib/gnutls_str.h
index b315c48..bf82072 100644
--- a/lib/gnutls_str.h
+++ b/lib/gnutls_str.h
@@ -70,7 +70,7 @@ int _gnutls_buffer_pop_datum_prefix (gnutls_buffer_st * buf,
                                      gnutls_datum_t * data);
 int _gnutls_buffer_to_datum (gnutls_buffer_st * str, gnutls_datum_t * data);
 
-int _gnutls_buffer_escape (gnutls_buffer_st * dest,
+int _gnutls_buffer_escape (gnutls_buffer_st * dest, int all, 
                            const char *const invalid_chars);
 int _gnutls_buffer_unescape (gnutls_buffer_st * dest);
 
diff --git a/lib/pkcs11.c b/lib/pkcs11.c
index 24a17cb..88607c2 100644
--- a/lib/pkcs11.c
+++ b/lib/pkcs11.c
@@ -677,7 +677,7 @@ pkcs11_url_to_info (const char *url, struct pkcs11_url_info 
*info)
   if ((p1 = strstr (url, "objecttype=")) != NULL)
     {
       p1 += sizeof ("objecttype=") - 1;
-      l = sizeof (info->model);
+      l = sizeof (info->type);
 
       ret = unescape_string (info->type, p1, &l, ';');
       if (ret < 0)
@@ -690,33 +690,21 @@ pkcs11_url_to_info (const char *url, struct 
pkcs11_url_info *info)
       || ((p1 = strstr (url, ":id=")) != NULL))
     {
       p1 += sizeof (";id=") - 1;
+      l = sizeof (info->certid_raw);
 
-      if ((p2 = strchr (p1, ';')) == NULL)
-        {
-          l = strlen (p1);
-        }
-      else
+      ret = unescape_string (info->certid_raw, p1, &l, ';');
+      if (ret < 0)
         {
-          l = p2 - p1;
+          goto cleanup;
         }
+      /* not null terminated */
+      info->certid_raw_size = l-1;
 
-      if (l > sizeof (info->id) - 1)
+      p2 = _gnutls_bin2hex(info->certid_raw, info->certid_raw_size,
+                           info->id, sizeof(info->id), ":");
+      if (p2 == NULL)
         {
-          gnutls_assert ();
           ret = GNUTLS_E_PARSING_ERROR;
-        }
-
-      memcpy (info->id, p1, l);
-      info->id[l] = 0;
-
-      /* convert to raw */
-      info->certid_raw_size = sizeof (info->certid_raw);
-      ret =
-        _gnutls_hex2bin (info->id, strlen (info->id),
-                         info->certid_raw, &info->certid_raw_size);
-      if (ret < 0)
-        {
-          gnutls_assert ();
           goto cleanup;
         }
     }
@@ -731,21 +719,24 @@ cleanup:
 
 #define INVALID_CHARS       "\\/\"'%&address@hidden <>{}[]()`|:;,.+-"
 
+/* Appends @tname to @dest under the name @p11name.
+ * init indicates whether it is the initial addition to buffer.
+ */
 static int
-append (gnutls_buffer_st * dest, const char *tname,
-        const char *p11name, int init)
+append (gnutls_buffer_st * dest, const void *tname, int tname_size,
+        const char *p11name, int all, int init)
 {
   gnutls_buffer_st tmpstr;
   int ret;
 
   _gnutls_buffer_init (&tmpstr);
-  if ((ret = _gnutls_buffer_append_str (&tmpstr, tname)) < 0)
+  if ((ret = _gnutls_buffer_append_data (&tmpstr, tname, tname_size)) < 0)
     {
       gnutls_assert ();
       goto cleanup;
     }
 
-  ret = _gnutls_buffer_escape (&tmpstr, INVALID_CHARS);
+  ret = _gnutls_buffer_escape (&tmpstr, all, INVALID_CHARS);
   if (ret < 0)
     {
       gnutls_assert ();
@@ -791,7 +782,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->token[0])
     {
-      ret = append (&str, info->token, "token", init);
+      ret = append (&str, info->token, strlen(info->token), "token", 0, init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -802,7 +793,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->serial[0])
     {
-      ret = append (&str, info->serial, "serial", init);
+      ret = append (&str, info->serial, strlen(info->serial), "serial", 0, 
init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -813,7 +804,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->model[0])
     {
-      ret = append (&str, info->model, "model", init);
+      ret = append (&str, info->model, strlen(info->model), "model", 0, init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -825,7 +816,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->manufacturer[0])
     {
-      ret = append (&str, info->manufacturer, "manufacturer", init);
+      ret = append (&str, info->manufacturer, strlen(info->manufacturer), 
"manufacturer", 0, init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -836,7 +827,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->label[0])
     {
-      ret = append (&str, info->label, "object", init);
+      ret = append (&str, info->label, strlen(info->label), "object", 0, init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -847,7 +838,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
   if (info->type[0])
     {
-      ret = append (&str, info->type, "objecttype", init);
+      ret = append (&str, info->type, strlen(info->type), "objecttype", 0, 
init);
       if (ret < 0)
         {
           gnutls_assert ();
@@ -861,8 +852,8 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
       if (info->lib_manufacturer[0])
         {
           ret =
-            append (&str, info->lib_manufacturer, "library-manufacturer",
-                    init);
+            append (&str, info->lib_manufacturer, 
strlen(info->lib_manufacturer), "library-manufacturer",
+                    0, init);
           if (ret < 0)
             {
               gnutls_assert ();
@@ -873,7 +864,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
 
       if (info->lib_desc[0])
         {
-          ret = append (&str, info->lib_desc, "library-description", init);
+          ret = append (&str, info->lib_desc, strlen(info->lib_desc), 
"library-description", 0, init);
           if (ret < 0)
             {
               gnutls_assert ();
@@ -887,7 +878,7 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
     {
       if (info->lib_version[0])
         {
-          ret = append (&str, info->lib_version, "library-version", init);
+          ret = append (&str, info->lib_version, strlen(info->lib_version), 
"library-version", 0, init);
           if (ret < 0)
             {
               gnutls_assert ();
@@ -897,9 +888,9 @@ pkcs11_info_to_url (const struct pkcs11_url_info *info,
         }
     }
 
-  if (info->id[0] != 0)
+  if (info->certid_raw_size > 0)
     {
-      ret = _gnutls_buffer_append_printf (&str, ";id=%s", info->id);
+      ret = append (&str, info->certid_raw, info->certid_raw_size, "id", 1, 
init);
       if (ret < 0)
         {
           gnutls_assert ();


hooks/post-receive
-- 
GNU gnutls



reply via email to

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