From 8b2641d36fa7f3ff5347196933715d23b668d762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 27 Aug 2015 20:03:46 +0200 Subject: [PATCH] Fix warning with MD/SHA ALT implementation fixes #239 --- ChangeLog | 2 ++ library/md2.c | 4 ++-- library/md4.c | 4 ++-- library/md5.c | 4 ++-- library/sha1.c | 4 ++-- library/sha256.c | 4 ++-- library/sha512.c | 4 ++-- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index a4772e011..d2bd81eed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -33,6 +33,8 @@ Bugfix * Fix memory corruption on client with overlong PSK identity, around SSL_MAX_CONTENT_LEN or higher - not triggerrable remotely (found by Aleksandrs Saveljevs) (#238) + * Fix unused function warning when using MBEDTLS_MDx_ALT or + MBEDTLS_SHAxxx_ALT (found by Henrik) (#239) Changes * The PEM parser now accepts a trailing space at end of lines (#226). diff --git a/library/md2.c b/library/md2.c index 3263a2230..88d679f47 100644 --- a/library/md2.c +++ b/library/md2.c @@ -47,13 +47,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_MD2_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_MD2_ALT) - static const unsigned char PI_SUBST[256] = { 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, diff --git a/library/md4.c b/library/md4.c index 563c65317..dcd9313d6 100644 --- a/library/md4.c +++ b/library/md4.c @@ -47,13 +47,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_MD4_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_MD4_ALT) - /* * 32-bit integer manipulation macros (little endian) */ diff --git a/library/md5.c b/library/md5.c index d8f216366..42c7c343c 100644 --- a/library/md5.c +++ b/library/md5.c @@ -46,13 +46,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_MD5_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_MD5_ALT) - /* * 32-bit integer manipulation macros (little endian) */ diff --git a/library/sha1.c b/library/sha1.c index 14331b3ac..ffad2287b 100644 --- a/library/sha1.c +++ b/library/sha1.c @@ -46,13 +46,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_SHA1_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_SHA1_ALT) - /* * 32-bit integer manipulation macros (big endian) */ diff --git a/library/sha256.c b/library/sha256.c index 28f09e5ae..4d8c868e9 100644 --- a/library/sha256.c +++ b/library/sha256.c @@ -46,13 +46,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_SHA256_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_SHA256_ALT) - /* * 32-bit integer manipulation macros (big endian) */ diff --git a/library/sha512.c b/library/sha512.c index 9e3e0e0a9..d1dc8faac 100644 --- a/library/sha512.c +++ b/library/sha512.c @@ -52,13 +52,13 @@ #endif /* MBEDTLS_PLATFORM_C */ #endif /* MBEDTLS_SELF_TEST */ +#if !defined(MBEDTLS_SHA512_ALT) + /* Implementation that should never be optimized out by the compiler */ static void mbedtls_zeroize( void *v, size_t n ) { volatile unsigned char *p = v; while( n-- ) *p++ = 0; } -#if !defined(MBEDTLS_SHA512_ALT) - /* * 64-bit integer manipulation macros (big endian) */