Fix unused function warning under certain configurations.
I refactored some code into the function mbedtls_constant_time_memcmp
in commit but this function is only used by GCM and
AEAD_ChaCha20_Poly1305 to check the tags. So this function is now
only enabled if either of these two ciphers is enabled.
#define MBEDTLS_CIPHER_MODE_STREAM
#endif
+
+#if defined(MBEDTLS_GCM_C) || defined(MBEDTLS_AEAD_CHACHA20_POLY1305_C)
/* Compare the contents of two buffers in constant time.
* Returns 0 if the contents are bitwise identical, otherwise returns
- * a non-zero value. */
+ * a non-zero value.
+ * This is currently only used by GCM and ChaCha20+Poly1305.
+ */
static int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t len )
{
const unsigned char *p1 = (const unsigned char*) v1;
@@ -84,6 +88,7 @@ static int mbedtls_constant_time_memcmp( const void *v1, const void *v2, size_t
return (int)diff;
}
+#endif /* MBEDTLS_GCM_C || MBEDTLS_AEAD_CHACHA20_POLY1305_C */
static int supported_init = 0;
