c++ compatibility of crypto.h

Brendan Doherty brendand at gentrack.com
Mon Dec 6 23:49:29 CET 2010


Hi, 

 

I've run into two problems when including gnutls/crypto.h into c++ code.

-          Missing extern "C"

-          Parameter names conflict with c++ keywords.

 

The patch below fixes the two problems.

 

Regards,

Brendan Doherty

Systems Architect

Gentrack Ltd

 

--- ../crypto.h 2010-12-07 11:46:25.000000000 +1300

+++ /gencore/gnutls-2.10.2/include/gnutls/crypto.h      2010-12-07
11:40:14.000000000 +1300

@@ -25,6 +25,11 @@

#ifndef GNUTLS_CRYPTO_H

# define GNUTLS_CRYPTO_H

+#ifdef __cplusplus

+extern "C"

+{

+#endif

+

typedef struct cipher_hd_st *gnutls_cipher_hd_t;

 int gnutls_cipher_init (gnutls_cipher_hd_t * handle,

@@ -266,17 +271,17 @@ typedef struct gnutls_crypto_pk

    * parameters, depending on the operation */

   int (*encrypt) (gnutls_pk_algorithm_t, gnutls_datum_t * ciphertext,

                  const gnutls_datum_t * plaintext,

-                 const gnutls_pk_params_st * public);

+                 const gnutls_pk_params_st * pub);

   int (*decrypt) (gnutls_pk_algorithm_t, gnutls_datum_t * plaintext,

                  const gnutls_datum_t * ciphertext,

-                 const gnutls_pk_params_st * private);

+                 const gnutls_pk_params_st * priv);

   int (*sign) (gnutls_pk_algorithm_t, gnutls_datum_t * signature,

               const gnutls_datum_t * data,

-              const gnutls_pk_params_st * private);

+              const gnutls_pk_params_st * priv);

   int (*verify) (gnutls_pk_algorithm_t, const gnutls_datum_t * data,

                 const gnutls_datum_t * signature,

-                const gnutls_pk_params_st * public);

+                const gnutls_pk_params_st * pub);

   int (*generate) (gnutls_pk_algorithm_t, unsigned int nbits,

                   gnutls_pk_params_st *);

@@ -346,4 +351,8 @@ int gnutls_crypto_pk_register2 (int prio

int gnutls_crypto_bigint_register2 (int priority, int version,

                                    const gnutls_crypto_bigint_st * s);

+#ifdef __cplusplus

+}

+#endif

+

#endif

-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20101207/4d5d327b/attachment.htm>


More information about the Gnutls-devel mailing list