From: Nikos Mavrogiannopoulos Date: Sat, 15 Jan 2011 19:43:10 +0000 (+0100) Subject: fixes in internal build with the new deprecated functions. We allow them to be used... X-Git-Tag: gnutls_2_11_7~87 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4b6f8f1d86459e38b2c29ce7df38f52ac136ad45;p=thirdparty%2Fgnutls.git fixes in internal build with the new deprecated functions. We allow them to be used since they are inter-dependent. --- diff --git a/doc/examples/ex-crq.c b/doc/examples/ex-crq.c index c8961d8799..4b5f337d13 100644 --- a/doc/examples/ex-crq.c +++ b/doc/examples/ex-crq.c @@ -9,6 +9,7 @@ #include #include #include +#include #include /* 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. diff --git a/lib/configure.ac b/lib/configure.ac index aca2e44c73..f6793bb42b 100644 --- a/lib/configure.ac +++ b/lib/configure.ac @@ -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 diff --git a/lib/includes/gnutls/compat.h b/lib/includes/gnutls/compat.h index fe2ba371b8..51d304cfcc 100644 --- a/lib/includes/gnutls/compat.h +++ b/lib/includes/gnutls/compat.h @@ -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 - #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, diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index b7725b959f..fe9909ab1d 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -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; diff --git a/lib/includes/gnutls/x509.h b/lib/includes/gnutls/x509.h index 9b42dcd05d..ffc0c5069d 100644 --- a/lib/includes/gnutls/x509.h +++ b/lib/includes/gnutls/x509.h @@ -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, diff --git a/src/certtool.c b/src/certtool.c index 826b05c759..c99ccf094f 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -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); } diff --git a/tests/crq_key_id.c b/tests/crq_key_id.c index da2461c645..2d7a9c455f 100644 --- a/tests/crq_key_id.c +++ b/tests/crq_key_id.c @@ -30,6 +30,7 @@ #include #include #include +#include #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 ();