Moved __cplusplus extern statement to include struct definitions as well.
diff --git a/include/polarssl/aes.h b/include/polarssl/aes.h
index 30fdf61..dfb9a0a 100644
--- a/include/polarssl/aes.h
+++ b/include/polarssl/aes.h
@@ -48,6 +48,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief AES context structure
*/
@@ -59,10 +63,6 @@
}
aes_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief AES key schedule (encryption)
*
diff --git a/include/polarssl/arc4.h b/include/polarssl/arc4.h
index 1672fa2..aa8feaa 100644
--- a/include/polarssl/arc4.h
+++ b/include/polarssl/arc4.h
@@ -35,6 +35,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief ARC4 context structure
*/
@@ -46,10 +50,6 @@
}
arc4_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief ARC4 key schedule
*
diff --git a/include/polarssl/asn1.h b/include/polarssl/asn1.h
index 8c7579d..61ea908 100644
--- a/include/polarssl/asn1.h
+++ b/include/polarssl/asn1.h
@@ -3,7 +3,7 @@
*
* \brief Generic ASN.1 parsing
*
- * Copyright (C) 2006-2011, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
diff --git a/include/polarssl/asn1write.h b/include/polarssl/asn1write.h
index f7efb20..459b282 100644
--- a/include/polarssl/asn1write.h
+++ b/include/polarssl/asn1write.h
@@ -3,7 +3,7 @@
*
* \brief ASN.1 buffer writing functionality
*
- * Copyright (C) 2006-2012, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -31,6 +31,10 @@
#define ASN1_CHK_ADD(g, f) if( ( ret = f ) < 0 ) return( ret ); else g += ret
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int asn1_write_len( unsigned char **p, unsigned char *start, size_t len );
int asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag );
#if defined(POLARSSL_BIGNUM_C)
@@ -45,4 +49,8 @@
int asn1_write_ia5_string( unsigned char **p, unsigned char *start,
char *text );
+#ifdef __cplusplus
+}
+#endif
+
#endif /* POLARSSL_ASN1_WRITE_H */
diff --git a/include/polarssl/bignum.h b/include/polarssl/bignum.h
index afa9e61..b1c43b7 100644
--- a/include/polarssl/bignum.h
+++ b/include/polarssl/bignum.h
@@ -158,6 +158,10 @@
#endif /* POLARSSL_HAVE_INT16 */
#endif /* POLARSSL_HAVE_INT8 */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief MPI structure
*/
@@ -169,10 +173,6 @@
}
mpi;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Initialize one MPI
*
diff --git a/include/polarssl/blowfish.h b/include/polarssl/blowfish.h
index 9b269b7..b1932e7 100644
--- a/include/polarssl/blowfish.h
+++ b/include/polarssl/blowfish.h
@@ -52,6 +52,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief Blowfish context structure
*/
@@ -62,10 +66,6 @@
}
blowfish_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Blowfish key schedule
*
diff --git a/include/polarssl/camellia.h b/include/polarssl/camellia.h
index 050c6cd..e46e175 100644
--- a/include/polarssl/camellia.h
+++ b/include/polarssl/camellia.h
@@ -48,6 +48,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief CAMELLIA context structure
*/
@@ -58,10 +62,6 @@
}
camellia_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief CAMELLIA key schedule (encryption)
*
diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h
index 2ffdf66..8aa8cb0 100644
--- a/include/polarssl/cipher.h
+++ b/include/polarssl/cipher.h
@@ -46,6 +46,10 @@
#define POLARSSL_ERR_CIPHER_INVALID_PADDING -0x6200 /**< Input data contains invalid padding and is rejected. */
#define POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED -0x6280 /**< Decryption of block requires a full block. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
POLARSSL_CIPHER_ID_NONE = 0,
POLARSSL_CIPHER_ID_NULL,
@@ -207,10 +211,6 @@
void *cipher_ctx;
} cipher_context_t;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Returns the list of ciphers supported by the generic cipher module.
*
diff --git a/include/polarssl/des.h b/include/polarssl/des.h
index d78b568..0dedf62 100644
--- a/include/polarssl/des.h
+++ b/include/polarssl/des.h
@@ -49,6 +49,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief DES context structure
*/
@@ -69,10 +73,6 @@
}
des3_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Set key parity on the given key to odd.
*
diff --git a/include/polarssl/dhm.h b/include/polarssl/dhm.h
index 48d9268..da787c3 100644
--- a/include/polarssl/dhm.h
+++ b/include/polarssl/dhm.h
@@ -3,7 +3,7 @@
*
* \brief Diffie-Hellman-Merkle key exchange
*
- * Copyright (C) 2006-2010, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -130,6 +130,10 @@
"EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179"\
"81BC087F2A7065B384B890D3191F2BFA"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief DHM context structure
*/
@@ -146,10 +150,6 @@
}
dhm_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Parse the ServerKeyExchange parameters
*
diff --git a/include/polarssl/ecdh.h b/include/polarssl/ecdh.h
index 7f6f4cb..2184ab9 100644
--- a/include/polarssl/ecdh.h
+++ b/include/polarssl/ecdh.h
@@ -29,6 +29,10 @@
#include "polarssl/ecp.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief ECDH context structure
*/
@@ -43,10 +47,6 @@
}
ecdh_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Generate a public key
*
diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h
index 8debda4..1d6310a 100644
--- a/include/polarssl/ecp.h
+++ b/include/polarssl/ecp.h
@@ -36,6 +36,10 @@
#define POLARSSL_ERR_ECP_BUFFER_TOO_SMALL -0x4F80 /**< The buffer is too small to write to. */
#define POLARSSL_ERR_ECP_GENERIC -0x4F00 /**< Generic ECP error */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief ECP point structure (jacobian coordinates)
*
@@ -134,11 +138,6 @@
*/
#define POLARSSL_ECP_TLS_NAMED_CURVE 3 /**< ECCurveType's named_curve */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Initialize a point (as zero)
*/
diff --git a/include/polarssl/gcm.h b/include/polarssl/gcm.h
index c703f3b..2bed342 100644
--- a/include/polarssl/gcm.h
+++ b/include/polarssl/gcm.h
@@ -3,7 +3,7 @@
*
* \brief Galois/Counter mode for AES
*
- * Copyright (C) 2006-2012, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -42,6 +42,10 @@
#define POLARSSL_ERR_GCM_AUTH_FAILED -0x0012 /**< Authenticated decryption failed. */
#define POLARSSL_ERR_GCM_BAD_INPUT -0x0014 /**< Bad input parameters to function. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief GCM context structure
*/
@@ -58,10 +62,6 @@
}
gcm_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief GCM initialization (encryption)
*
diff --git a/include/polarssl/havege.h b/include/polarssl/havege.h
index 53c4f38..5998903 100644
--- a/include/polarssl/havege.h
+++ b/include/polarssl/havege.h
@@ -3,7 +3,7 @@
*
* \brief HAVEGE: HArdware Volatile Entropy Gathering and Expansion
*
- * Copyright (C) 2006-2010, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -31,6 +31,10 @@
#define COLLECT_SIZE 1024
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief HAVEGE state structure
*/
@@ -42,10 +46,6 @@
}
havege_state;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief HAVEGE initialization
*
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index d9ab5e7..f7b8bd3 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
- * Copyright (C) 2006-2011, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -44,6 +44,10 @@
#define POLARSSL_ERR_MD_ALLOC_FAILED -0x5180 /**< Failed to allocate memory. */
#define POLARSSL_ERR_MD_FILE_IO_ERROR -0x5200 /**< Opening or reading of file failed. */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef enum {
POLARSSL_MD_NONE=0,
POLARSSL_MD_MD2,
@@ -131,10 +135,6 @@
NULL, /* md_ctx */ \
}
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Returns the list of digests supported by the generic digest module.
*
diff --git a/include/polarssl/md2.h b/include/polarssl/md2.h
index 1dc77c2..a8e23d0 100644
--- a/include/polarssl/md2.h
+++ b/include/polarssl/md2.h
@@ -37,6 +37,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief MD2 context structure
*/
@@ -52,10 +56,6 @@
}
md2_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief MD2 context setup
*
diff --git a/include/polarssl/md4.h b/include/polarssl/md4.h
index a08ea70..a5c9142 100644
--- a/include/polarssl/md4.h
+++ b/include/polarssl/md4.h
@@ -44,6 +44,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief MD4 context structure
*/
@@ -58,10 +62,6 @@
}
md4_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief MD4 context setup
*
diff --git a/include/polarssl/md5.h b/include/polarssl/md5.h
index c90789d..87474a7 100644
--- a/include/polarssl/md5.h
+++ b/include/polarssl/md5.h
@@ -44,6 +44,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief MD5 context structure
*/
@@ -58,10 +62,6 @@
}
md5_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief MD5 context setup
*
diff --git a/include/polarssl/pem.h b/include/polarssl/pem.h
index 801c57b..969faa2 100644
--- a/include/polarssl/pem.h
+++ b/include/polarssl/pem.h
@@ -46,6 +46,10 @@
#define POLARSSL_ERR_PEM_BAD_INPUT_DATA -0x1480 /**< Bad input parameters to function. */
/* \} name */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief PEM context structure
*/
@@ -57,10 +61,6 @@
}
pem_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief PEM context setup
*
diff --git a/include/polarssl/pkcs11.h b/include/polarssl/pkcs11.h
index 003d3f5..270eb6d 100644
--- a/include/polarssl/pkcs11.h
+++ b/include/polarssl/pkcs11.h
@@ -5,7 +5,7 @@
*
* \author Adriaan de Jong <dejong@fox-it.com>
*
- * Copyright (C) 2006-2011, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -45,6 +45,10 @@
#endif /* __ARMCC_VERSION */
#endif /*_MSC_VER */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* Context for PKCS #11 private keys.
*/
@@ -156,6 +160,10 @@
return ( (pkcs11_context *) ctx )->len;
}
+#ifdef __cplusplus
+}
+#endif
+
#endif /* POLARSSL_PKCS11_C */
#endif /* POLARSSL_PKCS11_H */
diff --git a/include/polarssl/rsa.h b/include/polarssl/rsa.h
index 9078111..7daa05a 100644
--- a/include/polarssl/rsa.h
+++ b/include/polarssl/rsa.h
@@ -3,7 +3,7 @@
*
* \brief The RSA public-key cryptosystem
*
- * Copyright (C) 2006-2010, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -59,6 +59,10 @@
#define RSA_SIGN 1
#define RSA_CRYPT 2
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief RSA context structure
*/
@@ -90,10 +94,6 @@
}
rsa_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief Initialize an RSA context
*
diff --git a/include/polarssl/sha1.h b/include/polarssl/sha1.h
index 81ea77d..1c18f8a 100644
--- a/include/polarssl/sha1.h
+++ b/include/polarssl/sha1.h
@@ -44,6 +44,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief SHA-1 context structure
*/
@@ -58,10 +62,6 @@
}
sha1_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief SHA-1 context setup
*
diff --git a/include/polarssl/sha2.h b/include/polarssl/sha2.h
index 795299e..9df46fb 100644
--- a/include/polarssl/sha2.h
+++ b/include/polarssl/sha2.h
@@ -44,6 +44,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief SHA-256 context structure
*/
@@ -59,10 +63,6 @@
}
sha2_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief SHA-256 context setup
*
diff --git a/include/polarssl/sha4.h b/include/polarssl/sha4.h
index e2ff3cc..450ef59 100644
--- a/include/polarssl/sha4.h
+++ b/include/polarssl/sha4.h
@@ -45,6 +45,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief SHA-512 context structure
*/
@@ -60,10 +64,6 @@
}
sha4_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief SHA-512 context setup
*
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index f95219c..1bc5893 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -254,6 +254,10 @@
#define POLARSSL_PREMASTER_SIZE POLARSSL_MPI_MAX_SIZE
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/*
* Generic function pointers for allowing external RSA private key
* implementations.
@@ -547,10 +551,6 @@
char peer_verify_data[36]; /*!< previous handshake verify data */
};
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)
#define SSL_CHANNEL_OUTBOUND 0
diff --git a/include/polarssl/timing.h b/include/polarssl/timing.h
index 355c63c..5ab000e 100644
--- a/include/polarssl/timing.h
+++ b/include/polarssl/timing.h
@@ -3,7 +3,7 @@
*
* \brief Portable interface to the CPU cycle counter
*
- * Copyright (C) 2006-2010, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -27,6 +27,10 @@
#ifndef POLARSSL_TIMING_H
#define POLARSSL_TIMING_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief timer structure
*/
@@ -35,10 +39,6 @@
unsigned char opaque[32];
};
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern volatile int alarmed;
/**
diff --git a/include/polarssl/version.h b/include/polarssl/version.h
index 4f73ee2..9bab3ca 100644
--- a/include/polarssl/version.h
+++ b/include/polarssl/version.h
@@ -3,7 +3,7 @@
*
* \brief Run-time version information
*
- * Copyright (C) 2006-2012, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -52,6 +52,10 @@
#if defined(POLARSSL_VERSION_C)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* Get the version number.
*
@@ -76,6 +80,10 @@
*/
void version_get_string_full( char *string );
+#ifdef __cplusplus
+}
+#endif
+
#endif /* POLARSSL_VERSION_C */
#endif /* version.h */
diff --git a/include/polarssl/x509.h b/include/polarssl/x509.h
index 8baee15..86624ec 100644
--- a/include/polarssl/x509.h
+++ b/include/polarssl/x509.h
@@ -3,7 +3,7 @@
*
* \brief X.509 certificate and private key decoding
*
- * Copyright (C) 2006-2011, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -140,6 +140,10 @@
#define X509_FORMAT_DER 1
#define X509_FORMAT_PEM 2
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \addtogroup x509_module
* \{ */
@@ -320,10 +324,6 @@
x509_raw;
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \name Functions to read in DHM parameters, a certificate, CRL or private RSA key
* \{
diff --git a/include/polarssl/x509write.h b/include/polarssl/x509write.h
index 35b318f..0d94f01 100644
--- a/include/polarssl/x509write.h
+++ b/include/polarssl/x509write.h
@@ -3,7 +3,7 @@
*
* \brief X509 buffer writing functionality
*
- * Copyright (C) 2006-2012, Brainspark B.V.
+ * Copyright (C) 2006-2013, Brainspark B.V.
*
* This file is part of PolarSSL (http://www.polarssl.org)
* Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
@@ -33,6 +33,10 @@
#include "rsa.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
typedef struct _x509_req_name
{
char oid[128];
@@ -47,6 +51,10 @@
int x509_write_cert_req( unsigned char *buf, size_t size, rsa_context *rsa,
x509_req_name *req_name, md_type_t md_alg );
+#ifdef __cplusplus
+}
+#endif
+
#endif /* POLARSSL_X509_WRITE_C */
#endif /* POLARSSL_X509_WRITE_H */
diff --git a/include/polarssl/xtea.h b/include/polarssl/xtea.h
index 207e188..4b435ae 100644
--- a/include/polarssl/xtea.h
+++ b/include/polarssl/xtea.h
@@ -47,6 +47,10 @@
// Regular implementation
//
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/**
* \brief XTEA context structure
*/
@@ -56,10 +60,6 @@
}
xtea_context;
-#ifdef __cplusplus
-extern "C" {
-#endif
-
/**
* \brief XTEA key schedule
*