Add POLARSSL_DEPRECATED_{WARNING,REMOVED}
diff --git a/include/polarssl/check_config.h b/include/polarssl/check_config.h
index 1062434..a668cf8 100644
--- a/include/polarssl/check_config.h
+++ b/include/polarssl/check_config.h
@@ -30,6 +30,11 @@
#ifndef POLARSSL_CHECK_CONFIG_H
#define POLARSSL_CHECK_CONFIG_H
+#if defined(POLARSSL_DEPRECATED_WARNING) && \
+ !defined(__GCC__) && !defined(__clang__)
+#error "POLARSSL_DEPRECATED_WARNING only works with GCC and Clang"
+#endif
+
#if defined(POLARSSL_AESNI_C) && !defined(POLARSSL_HAVE_ASM)
#error "POLARSSL_AESNI_C defined, but not all prerequisites"
#endif
diff --git a/include/polarssl/cipher.h b/include/polarssl/cipher.h
index 6773f61..ef8d281 100644
--- a/include/polarssl/cipher.h
+++ b/include/polarssl/cipher.h
@@ -372,6 +372,12 @@
*/
int cipher_init_ctx( cipher_context_t *ctx, const cipher_info_t *cipher_info );
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
/**
* \brief Free the cipher-specific context of ctx. Freeing ctx
* itself remains the responsibility of the caller.
@@ -382,7 +388,9 @@
*
* \returns 0
*/
-int cipher_free_ctx( cipher_context_t *ctx );
+int cipher_free_ctx( cipher_context_t *ctx ) DEPRECATED;
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
/**
* \brief Returns the block size of the given cipher.
diff --git a/include/polarssl/config.h b/include/polarssl/config.h
index be7da28..63db5ee 100644
--- a/include/polarssl/config.h
+++ b/include/polarssl/config.h
@@ -179,6 +179,34 @@
//#define POLARSSL_PLATFORM_FPRINTF_ALT
//#define POLARSSL_PLATFORM_PRINTF_ALT
//#define POLARSSL_PLATFORM_SNPRINTF_ALT
+
+/**
+ * \def POLARSSL_DEPRECATED_WARNING
+ *
+ * Mark deprecated functions so that they generate a warning if used.
+ * Functions deprecated in one version will usually be removed in the next
+ * version. You can enable this to help you prepare the transition to a new
+ * major version by making sure your code is not using these functions.
+ *
+ * This only works with GCC and Clang. With other compilers, you may want to
+ * use POLARSSL_DEPRECATED_REMOVED
+ *
+ * Uncomment to get warnings on using deprecated functions.
+ */
+//#define POLARSSL_DEPRECATED_WARNING
+
+/**
+ * \def POLARSSL_DEPRECATED_REMOVED
+ *
+ * Remove deprecated functions so that they generate an error if used.
+ * Functions deprecated in one version will usually be removed in the next
+ * version. You can enable this to help you prepare the transition to a new
+ * major version by making sure your code is not using these functions.
+ *
+ * Uncomment to get errors on using deprecated functions.
+ */
+//#define POLARSSL_DEPRECATED_REMOVED
+
/* \} name SECTION: System support */
/**
diff --git a/include/polarssl/md.h b/include/polarssl/md.h
index 95da80b..303aee8 100644
--- a/include/polarssl/md.h
+++ b/include/polarssl/md.h
@@ -200,6 +200,12 @@
*/
int md_init_ctx( md_context_t *ctx, const md_info_t *md_info );
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
/**
* \brief Free the message-specific context of ctx. Freeing ctx itself
* remains the responsibility of the caller.
@@ -210,7 +216,9 @@
*
* \returns 0
*/
-int md_free_ctx( md_context_t *ctx );
+int md_free_ctx( md_context_t *ctx ) DEPRECATED;
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
/**
* \brief Returns the size of the message digest output.
diff --git a/include/polarssl/memory.h b/include/polarssl/memory.h
index 8312beb..8b8ac5d 100644
--- a/include/polarssl/memory.h
+++ b/include/polarssl/memory.h
@@ -37,16 +37,26 @@
#include "platform.h"
#include "memory_buffer_alloc.h"
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
/**
* \brief Set malloc() / free() callback
*
* \deprecated Use platform_set_malloc_free instead
*/
int memory_set_own( void * (*malloc_func)( size_t ),
+ void (*free_func)( void * ) ) DEPRECATED;
+int memory_set_own( void * (*malloc_func)( size_t ),
void (*free_func)( void * ) )
{
return platform_set_malloc_free( malloc_func, free_func );
}
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
#endif /* memory.h */
diff --git a/include/polarssl/pbkdf2.h b/include/polarssl/pbkdf2.h
index e842c83..28987b3 100644
--- a/include/polarssl/pbkdf2.h
+++ b/include/polarssl/pbkdf2.h
@@ -45,6 +45,12 @@
extern "C" {
#endif
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
/**
* \brief PKCS#5 PBKDF2 using HMAC
*
@@ -64,7 +70,7 @@
int pbkdf2_hmac( md_context_t *ctx, const unsigned char *password,
size_t plen, const unsigned char *salt, size_t slen,
unsigned int iteration_count,
- uint32_t key_length, unsigned char *output );
+ uint32_t key_length, unsigned char *output ) DEPRECATED;
/**
* \brief Checkup routine
@@ -73,7 +79,9 @@
*
* \return 0 if successful, or 1 if the test failed
*/
-int pbkdf2_self_test( int verbose );
+int pbkdf2_self_test( int verbose ) DEPRECATED;
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
#ifdef __cplusplus
}
diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h
index 8e82137..cd9f770 100644
--- a/include/polarssl/ssl.h
+++ b/include/polarssl/ssl.h
@@ -1213,6 +1213,12 @@
int ssl_set_own_cert( ssl_context *ssl, x509_crt *own_cert,
pk_context *pk_key );
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
#if defined(POLARSSL_RSA_C)
/**
* \brief Set own certificate chain and private RSA key
@@ -1230,7 +1236,7 @@
* \return 0 on success, or a specific error code.
*/
int ssl_set_own_cert_rsa( ssl_context *ssl, x509_crt *own_cert,
- rsa_context *rsa_key );
+ rsa_context *rsa_key ) DEPRECATED;
#endif /* POLARSSL_RSA_C */
/**
@@ -1261,7 +1267,9 @@
void *rsa_key,
rsa_decrypt_func rsa_decrypt,
rsa_sign_func rsa_sign,
- rsa_key_len_func rsa_key_len );
+ rsa_key_len_func rsa_key_len ) DEPRECATED;
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
#endif /* POLARSSL_X509_CRT_PARSE_C */
#if defined(POLARSSL_KEY_EXCHANGE__SOME__PSK_ENABLED)
diff --git a/include/polarssl/x509.h b/include/polarssl/x509.h
index 9dda082..0dece06 100644
--- a/include/polarssl/x509.h
+++ b/include/polarssl/x509.h
@@ -225,6 +225,12 @@
*/
int x509_serial_gets( char *buf, size_t size, const x509_buf *serial );
+#if ! defined(POLARSSL_DEPRECATED_REMOVED)
+#if defined(POLARSSL_DEPRECATED_WARNING)
+#define DEPRECATED __attribute__((deprecated))
+#else
+#define DEPRECATED
+#endif
/**
* \brief Give an known OID, return its descriptive string.
*
@@ -237,7 +243,7 @@
* \return Return a string if the OID is known,
* or NULL otherwise.
*/
-const char *x509_oid_get_description( x509_buf *oid );
+const char *x509_oid_get_description( x509_buf *oid ) DEPRECATED;
/**
* \brief Give an OID, return a string version of its OID number.
@@ -251,7 +257,9 @@
* \return Length of the string written (excluding final NULL) or
* POLARSSL_ERR_OID_BUF_TO_SMALL in case of error
*/
-int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid );
+int x509_oid_get_numeric_string( char *buf, size_t size, x509_buf *oid ) DEPRECATED;
+#undef DEPRECATED
+#endif /* POLARSSL_DEPRECATED_REMOVED */
/**
* \brief Check a given x509_time against the system time and check