gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, master, updated. gnutls_3_1_2-49-g29d8329


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, master, updated. gnutls_3_1_2-49-g29d8329
Date: Sun, 07 Oct 2012 09:07:47 +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=29d8329019ef8c17aecb8a757aea853ffb7f48c5

The branch, master has been updated
       via  29d8329019ef8c17aecb8a757aea853ffb7f48c5 (commit)
      from  531bac41a0ee19158f0722937d0c9efafbc3bb14 (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 29d8329019ef8c17aecb8a757aea853ffb7f48c5
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sun Oct 7 11:01:29 2012 +0200

    Added helper functions gnutls_pubkey_import_openpgp_raw() and 
gnutls_pubkey_import_x509_raw().

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

Summary of changes:
 NEWS                           |    2 +
 doc/cha-tokens.texi            |    5 ++
 lib/gnutls_privkey.c           |    2 -
 lib/gnutls_pubkey.c            |  111 ++++++++++++++++++++++++++++++++++++++++
 lib/includes/gnutls/abstract.h |   11 ++++
 lib/libgnutls.map              |    2 +
 6 files changed, 131 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index a7f8d3f..f22d2ca 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,8 @@ gnutls_openpgp_crt_export2: Added
 gnutls_openpgp_privkey_export2: Added
 gnutls_pkcs11_obj_export2: Added
 gnutls_pkcs12_export2: Added
+gnutls_pubkey_import_openpgp_raw: Added
+gnutls_pubkey_import_x509_raw: Added
 dane_query_init: Added
 dane_query_deinit: Added
 dane_query_resolve_tlsa: Added
diff --git a/doc/cha-tokens.texi b/doc/cha-tokens.texi
index b290ff5..ad61b15 100644
--- a/doc/cha-tokens.texi
+++ b/doc/cha-tokens.texi
@@ -73,6 +73,11 @@ sequence.
 
 @showfuncB{gnutls_pubkey_export,gnutls_pubkey_export2}
 
+Other helper functions that allow directly importing from raw X.509 or
+OpenPGP structures are shown below. 
+
address@hidden,gnutls_pubkey_import_openpgp_raw}
+
 An important function is @funcref{gnutls_pubkey_import_url} which will import
 public keys from URLs that identify objects stored in tokens (see @ref{Smart 
cards and HSMs} and @ref{Trusted Platform Module}).
 A function to check for a supported by GnuTLS URL is 
@funcref{gnutls_url_is_supported}.
diff --git a/lib/gnutls_privkey.c b/lib/gnutls_privkey.c
index 00187a5..f718b7c 100644
--- a/lib/gnutls_privkey.c
+++ b/lib/gnutls_privkey.c
@@ -947,8 +947,6 @@ cleanup:
   return ret;
 }
 
-
-
 /**
  * gnutls_privkey_import_url:
  * @key: A key of type #gnutls_privkey_t
diff --git a/lib/gnutls_pubkey.c b/lib/gnutls_pubkey.c
index 21bea55..36e9cee 100644
--- a/lib/gnutls_pubkey.c
+++ b/lib/gnutls_pubkey.c
@@ -467,6 +467,67 @@ gnutls_pubkey_get_openpgp_key_id (gnutls_pubkey_t key, 
unsigned int flags,
   return 0;
 }
 
+/**
+ * gnutls_pubkey_import_openpgp_raw:
+ * @pkey: The public key
+ * @data: The public key data to be imported
+ * @format: The format of the public key
+ * @keyid: The key id to use (optional)
+ * @flags: Should be zero
+ *
+ * This function will import the given public key to the abstract
+ * #gnutls_pubkey_t structure. 
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ *   negative error value.
+ *
+ * Since: 3.1.3
+ **/
+int gnutls_pubkey_import_openpgp_raw (gnutls_pubkey_t pkey,
+                                      const gnutls_datum_t * data,
+                                      gnutls_openpgp_crt_fmt_t format,
+                                      const gnutls_openpgp_keyid_t keyid,
+                                      unsigned int flags)
+{
+  gnutls_openpgp_crt_t xpriv;
+  int ret;
+  
+  ret = gnutls_openpgp_crt_init(&xpriv);
+  if (ret < 0)
+    return gnutls_assert_val(ret);
+
+  ret = gnutls_openpgp_crt_import(xpriv, data, format);
+  if (ret < 0)
+    {
+      gnutls_assert();
+      goto cleanup;
+    }
+
+  if(keyid)
+    {
+      ret = gnutls_openpgp_crt_set_preferred_key_id(xpriv, keyid);
+      if (ret < 0)
+        {
+          gnutls_assert();
+          goto cleanup;
+        }
+    }
+
+  ret = gnutls_pubkey_import_openpgp(pkey, xpriv, flags);
+  if (ret < 0)
+    {
+      gnutls_assert();
+      goto cleanup;
+    }
+    
+  ret = 0;
+  
+cleanup:
+  gnutls_openpgp_crt_deinit(xpriv);
+  
+  return ret;
+}
+
 #endif
 
 /**
@@ -1951,3 +2012,53 @@ void gnutls_pubkey_set_pin_function (gnutls_pubkey_t key,
   key->pin.cb = fn;
   key->pin.data = userdata;
 }
+
+/**
+ * gnutls_pubkey_import_x509_raw:
+ * @pkey: The public key
+ * @data: The public key data to be imported
+ * @format: The format of the public key
+ * @flags: should be zero
+ *
+ * This function will import the given public key to the abstract
+ * #gnutls_pubkey_t structure. 
+ *
+ * Returns: On success, %GNUTLS_E_SUCCESS (0) is returned, otherwise a
+ *   negative error value.
+ *
+ * Since: 3.1.0
+ **/
+int gnutls_pubkey_import_x509_raw (gnutls_pubkey_t pkey,
+                                    const gnutls_datum_t * data,
+                                    gnutls_x509_crt_fmt_t format,
+                                    unsigned int flags)
+{
+  gnutls_x509_crt_t xpriv;
+  int ret;
+  
+  ret = gnutls_x509_crt_init(&xpriv);
+  if (ret < 0)
+    return gnutls_assert_val(ret);
+
+  ret = gnutls_x509_crt_import(xpriv, data, format);
+  if (ret < 0)
+    {
+      gnutls_assert();
+      goto cleanup;
+    }
+
+  ret = gnutls_pubkey_import_x509(pkey, xpriv, flags);
+  if (ret < 0)
+    {
+      gnutls_assert();
+      goto cleanup;
+    }
+
+  return 0;
+  
+cleanup:
+  gnutls_x509_crt_deinit(xpriv);
+
+  return ret;
+}
+
diff --git a/lib/includes/gnutls/abstract.h b/lib/includes/gnutls/abstract.h
index b96d630..36aa89c 100644
--- a/lib/includes/gnutls/abstract.h
+++ b/lib/includes/gnutls/abstract.h
@@ -69,6 +69,17 @@ int gnutls_pubkey_import_pkcs11 (gnutls_pubkey_t key,
 int gnutls_pubkey_import_openpgp (gnutls_pubkey_t key,
                                   gnutls_openpgp_crt_t crt,
                                   unsigned int flags);
+
+int gnutls_pubkey_import_openpgp_raw (gnutls_pubkey_t pkey,
+                                      const gnutls_datum_t * data,
+                                      gnutls_openpgp_crt_fmt_t format,
+                                      const gnutls_openpgp_keyid_t keyid,
+                                      unsigned int flags);
+int gnutls_pubkey_import_x509_raw (gnutls_pubkey_t pkey,
+                                    const gnutls_datum_t * data,
+                                    gnutls_x509_crt_fmt_t format,
+                                    unsigned int flags);
+
 int
 gnutls_pubkey_import_privkey (gnutls_pubkey_t key, gnutls_privkey_t pkey,
                               unsigned int usage, unsigned int flags);
diff --git a/lib/libgnutls.map b/lib/libgnutls.map
index 578e159..c795ab1 100644
--- a/lib/libgnutls.map
+++ b/lib/libgnutls.map
@@ -854,6 +854,8 @@ GNUTLS_3_1_0 {
        gnutls_openpgp_privkey_export2;
        gnutls_pkcs11_obj_export2;
        gnutls_pkcs12_export2;
+       gnutls_pubkey_import_openpgp_raw;
+       gnutls_pubkey_import_x509_raw;
 } GNUTLS_3_0_0;
 
 GNUTLS_PRIVATE {


hooks/post-receive
-- 
GNU gnutls



reply via email to

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