]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
fixes in internal build with the new deprecated functions. We allow them to be used...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 15 Jan 2011 19:43:10 +0000 (20:43 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 15 Jan 2011 19:57:18 +0000 (20:57 +0100)
doc/examples/ex-crq.c
lib/configure.ac
lib/includes/gnutls/compat.h
lib/includes/gnutls/gnutls.h.in
lib/includes/gnutls/x509.h
src/certtool.c
tests/crq_key_id.c

index c8961d8799db84cdd3674099ae4ef428e94cb24c..4b5f337d132e244c05e34be57ccac169bd85ad8b 100644 (file)
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
+#include <gnutls/abstract.h>
 #include <time.h>
 
 /* This example will generate a private key and a certificate
@@ -20,6 +21,7 @@ main (void)
 {
   gnutls_x509_crq_t crq;
   gnutls_x509_privkey_t key;
+  gnutls_privkey_t pkey; /* object used for signing */
   unsigned char buffer[10 * 1024];
   size_t buffer_size = sizeof (buffer);
   unsigned int bits;
@@ -32,6 +34,7 @@ main (void)
   gnutls_x509_crq_init (&crq);
 
   gnutls_x509_privkey_init (&key);
+  gnutls_privkey_init (&pkey);
 
   /* Generate an RSA key of moderate security.
    */
@@ -60,7 +63,8 @@ main (void)
 
   /* Self sign the certificate request.
    */
-  gnutls_x509_crq_sign (crq, key);
+  gnutls_privkey_import_x509( pkey, key, 0);
+  gnutls_x509_crq_privkey_sign (crq, pkey, GNUTLS_DIG_SHA1, 0);
 
   /* Export the PEM encoded certificate request, and
    * display it.
index aca2e44c739faf500cc2f26f8f0c6611e5408272..f6793bb42b305beb98713924a44396ddb5884fce 100644 (file)
@@ -97,7 +97,7 @@ AC_SUBST([WARN_CFLAGS])
 AC_PROG_CXX
 AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no")
 
-AC_DEFINE([GNUTLS_COMPAT_H], 1, [Make sure we don't use old features in code.])
+AC_DEFINE([GNUTLS_INTERNAL_BUILD], 1, [We allow temporarily usage of deprecated functions - until they are removed.])
 
 AC_CONFIG_FILES([
   Makefile
index fe2ba371b807aa52d830452e435a5419fdbb3f62..51d304cfcc037fec66c401cdc6a3ee7d17bf7801 100644 (file)
@@ -7,9 +7,11 @@
 
 #define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
 
+#if !defined(GNUTLS_INTERNAL_BUILD)
 #if _GNUTLS_GCC_VERSION >= 30100
 #define _GNUTLS_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))
 #endif
+#endif
 
 #endif /* __GNUC__ */
 
@@ -17,8 +19,6 @@
 #define _GNUTLS_GCC_ATTR_DEPRECATED
 #endif
 
-#include <gnutls/x509.h>
-
 #define gnutls_cipher_algorithm gnutls_cipher_algorithm_t
 #define gnutls_kx_algorithm gnutls_kx_algorithm_t
 #define gnutls_paramsype gnutls_paramsype_t
@@ -289,6 +289,7 @@ gnutls_sign_callback_get (gnutls_session_t session, void **userdata)
                               _GNUTLS_GCC_ATTR_DEPRECATED;
 
 
+
   /* gnutls_x509_crl_privkey_sign */
   int gnutls_x509_crl_sign (gnutls_x509_crl_t crl,
                             gnutls_x509_crt_t issuer,
index b7725b959f48ec026e164374aabb3ecaa3aca364..fe9909ab1df4c07d989138257826547afaa75a0a 100644 (file)
@@ -1090,6 +1090,9 @@ extern "C"
   struct gnutls_x509_crt_int;
   typedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;
 
+  struct gnutls_x509_crq_int;
+  typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;
+
   struct gnutls_openpgp_keyring_int;
   typedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;
 
index 9b42dcd05d76f0926fbcda8bc0db9da2028e4f65..ffc0c5069d965b33ab4bc5c561dd3b894a102c99 100644 (file)
@@ -698,8 +698,6 @@ extern "C"
 
 /* Certificate request stuff.
  */
-  struct gnutls_x509_crq_int;
-  typedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;
 
   int gnutls_x509_crq_print (gnutls_x509_crq_t crq,
                              gnutls_certificate_print_formats_t format,
index 826b05c75990da89d4e18e3c12f4dc6ca91dc098..c99ccf094fdec4a3c6507a389f4e52ee9afdca5b 100644 (file)
@@ -923,6 +923,7 @@ generate_signed_crl (common_info_st * cinfo)
   gnutls_x509_crl_t crl;
   int result;
   gnutls_x509_privkey_t ca_key;
+  gnutls_privkey_t ca_pkey;
   gnutls_x509_crt_t ca_crt;
 
   fprintf (stderr, "Generating a signed CRL...\n");
@@ -931,14 +932,23 @@ generate_signed_crl (common_info_st * cinfo)
   ca_crt = load_ca_cert (cinfo);
   crl = generate_crl (ca_crt, cinfo);
 
+  result = gnutls_privkey_init(&ca_pkey);
+  if (result < 0)
+    error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (result));
+
+  result = gnutls_privkey_import_x509(ca_pkey, ca_key, 0);
+  if (result < 0)
+    error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (result));
+
   fprintf (stderr, "\n");
 
-  result = gnutls_x509_crl_sign (crl, ca_crt, ca_key);
+  result = gnutls_x509_crl_privkey_sign(crl, ca_crt, ca_pkey, GNUTLS_DIG_SHA1, 0);
   if (result < 0)
-    error (EXIT_FAILURE, 0, "crl_sign: %s", gnutls_strerror (result));
+    error (EXIT_FAILURE, 0, "crl_privkey_sign: %s", gnutls_strerror (result));
 
   print_crl_info (crl, stderr);
 
+  gnutls_privkey_deinit( ca_pkey);
   gnutls_x509_crl_deinit (crl);
 }
 
@@ -1751,6 +1761,7 @@ generate_request (common_info_st * cinfo)
 {
   gnutls_x509_crq_t crq;
   gnutls_x509_privkey_t key;
+  gnutls_privkey_t pkey;
   int ret, ca_status, path_len;
   const char *pass;
   unsigned int usage = 0;
@@ -1761,6 +1772,10 @@ generate_request (common_info_st * cinfo)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "crq_init: %s", gnutls_strerror (ret));
 
+  ret = gnutls_privkey_init (&pkey);
+  if (ret < 0)
+    error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret));
+
   /* Load the private key.
    */
   key = load_private_key (0, cinfo);
@@ -1771,6 +1786,10 @@ generate_request (common_info_st * cinfo)
       print_private_key (key);
     }
 
+  ret = gnutls_privkey_import_x509(pkey, key, 0);
+  if (ret < 0)
+    error (EXIT_FAILURE, 0, "privkey_import_x509: %s", gnutls_strerror (ret));
+
   /* Set the DN.
    */
   get_country_crq_set (crq);
@@ -1892,13 +1911,14 @@ generate_request (common_info_st * cinfo)
   if (ret < 0)
     error (EXIT_FAILURE, 0, "set_key: %s", gnutls_strerror (ret));
 
-  ret = gnutls_x509_crq_sign (crq, key);
+  ret = gnutls_x509_crq_privkey_sign (crq, pkey, GNUTLS_DIG_SHA1, 0);
   if (ret < 0)
     error (EXIT_FAILURE, 0, "sign: %s", gnutls_strerror (ret));
 
   print_crq_info (crq, outfile);
 
   gnutls_x509_crq_deinit (crq);
+  gnutls_privkey_deinit( pkey);
   gnutls_x509_privkey_deinit (key);
 
 }
index da2461c6454984032f849f121fb0aed4c25840a3..2d7a9c455f7070c91d345e5a92f97dfe69f7990d 100644 (file)
@@ -30,6 +30,7 @@
 #include <gcrypt.h>
 #include <gnutls/gnutls.h>
 #include <gnutls/x509.h>
+#include <gnutls/abstract.h>
 
 #include "utils.h"
 
@@ -43,6 +44,7 @@ void
 doit (void)
 {
   gnutls_x509_privkey_t pkey;
+  gnutls_privkey_t abs_pkey;
   gnutls_x509_crq_t crq;
 
   size_t pkey_key_id_len;
@@ -75,6 +77,12 @@ doit (void)
           fail ("gnutls_x509_privkey_init: %d\n", ret);
         }
 
+      ret = gnutls_privkey_init (&abs_pkey);
+      if (ret < 0)
+        {
+          fail ("gnutls_privkey_init: %d\n", ret);
+        }
+
       ret = gnutls_x509_privkey_generate (pkey, algorithm, 1024, 0);
       if (ret < 0)
         {
@@ -123,7 +131,13 @@ doit (void)
           fail ("gnutls_x509_crq_set_dn_by_oid: %d\n", ret);
         }
 
-      ret = gnutls_x509_crq_sign (crq, pkey);
+      ret = gnutls_privkey_import_x509( abs_pkey, pkey, 0);
+      if (ret < 0)
+        {
+          fail ("gnutls_privkey_import_x509: %d\n", ret);
+        }
+
+      ret = gnutls_x509_crq_privkey_sign (crq, abs_pkey, GNUTLS_DIG_SHA1, 0);
       if (ret)
         {
           fail ("gnutls_x509_crq_sign: %d\n", ret);
@@ -177,6 +191,7 @@ doit (void)
 
       gnutls_x509_crq_deinit (crq);
       gnutls_x509_privkey_deinit (pkey);
+      gnutls_privkey_deinit (abs_pkey);
     }
 
   gnutls_global_deinit ();