Fix unused function warning under certain configurations.

I refactored some code into the function mbedtls_constant_time_memcmp
in commit 7aad291 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.
This commit is contained in:
Daniel King 2016-05-18 13:38:22 -03:00 committed by Manuel Pégourié-Gonnard
parent 5b7f1d8035
commit b9a069d096

View File

@ -69,9 +69,13 @@
#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;