#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
{
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;
gnutls_x509_crq_init (&crq);
gnutls_x509_privkey_init (&key);
+ gnutls_privkey_init (&pkey);
/* Generate an RSA key of moderate security.
*/
/* 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.
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
#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__ */
#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
_GNUTLS_GCC_ATTR_DEPRECATED;
+
/* gnutls_x509_crl_privkey_sign */
int gnutls_x509_crl_sign (gnutls_x509_crl_t crl,
gnutls_x509_crt_t issuer,
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;
/* 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,
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");
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);
}
{
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;
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);
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);
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);
}
#include <gcrypt.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
+#include <gnutls/abstract.h>
#include "utils.h"
doit (void)
{
gnutls_x509_privkey_t pkey;
+ gnutls_privkey_t abs_pkey;
gnutls_x509_crq_t crq;
size_t pkey_key_id_len;
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)
{
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);
gnutls_x509_crq_deinit (crq);
gnutls_x509_privkey_deinit (pkey);
+ gnutls_privkey_deinit (abs_pkey);
}
gnutls_global_deinit ();