From 497313978f7f7a1740641b3eaccd09e958053ce2 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Fri, 20 Jan 2017 11:08:37 -0800 Subject: [PATCH] Multicast 1. Opt-out the wolfmath code if not using big integers. 2. Opt-in a few functions when using lean PSK and DTLS. 3. Add a couple (void)heap to hush the compiler for usused variables in lean PSK. 4. Add include limits.h to internal.h if CHAR_BIT isn't defined. This is mainly for DTLS with lean PSK. --- src/internal.c | 7 +++++-- src/ssl.c | 2 ++ wolfcrypt/src/wolfmath.c | 3 +++ wolfssl/internal.h | 5 +++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index 1ee94d260..194cece43 100644 --- a/src/internal.c +++ b/src/internal.c @@ -329,7 +329,8 @@ static INLINE void c16toa(word16 u16, byte* c) #if !defined(NO_OLD_TLS) || defined(HAVE_CHACHA) || defined(HAVE_AESCCM) \ - || defined(HAVE_AESGCM) || defined(WOLFSSL_SESSION_EXPORT) + || defined(HAVE_AESGCM) || defined(WOLFSSL_SESSION_EXPORT) \ + || defined(WOLFSSL_DTLS) /* convert 32 bit integer to opaque */ static INLINE void c32toa(word32 u32, byte* c) { @@ -4012,7 +4013,7 @@ void FreeSSL(WOLFSSL* ssl, void* heap) #if !defined(NO_OLD_TLS) || defined(HAVE_CHACHA) || defined(HAVE_AESCCM) \ - || defined(HAVE_AESGCM) + || defined(HAVE_AESGCM) || defined(WOLFSSL_DTLS) static INLINE void GetSEQIncrement(WOLFSSL* ssl, int verify, word32 seq[2]) { if (verify) { @@ -4116,6 +4117,7 @@ DtlsMsg* DtlsMsgNew(word32 sz, void* heap) { DtlsMsg* msg = NULL; + (void)heap; msg = (DtlsMsg*)XMALLOC(sizeof(DtlsMsg), heap, DYNAMIC_TYPE_DTLS_MSG); if (msg != NULL) { @@ -4172,6 +4174,7 @@ static DtlsFrag* CreateFragment(word32* begin, word32 end, const byte* data, DtlsFrag* newFrag; word32 added = end - *begin + 1; + (void)heap; newFrag = (DtlsFrag*)XMALLOC(sizeof(DtlsFrag), heap, DYNAMIC_TYPE_DTLS_FRAG); if (newFrag != NULL) { diff --git a/src/ssl.c b/src/ssl.c index bf28bcd28..9d79609a2 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -7654,6 +7654,7 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl, WOLFSSL_ENTER("DTLSv1_2_client_method_ex"); if (method) InitSSL_Method(method, MakeDTLSv1_2()); + (void)heap; return method; } #endif @@ -8005,6 +8006,7 @@ int wolfSSL_DTLS_SetCookieSecret(WOLFSSL* ssl, InitSSL_Method(method, MakeDTLSv1_2()); method->side = WOLFSSL_SERVER_END; } + (void)heap; return method; } #endif diff --git a/wolfcrypt/src/wolfmath.c b/wolfcrypt/src/wolfmath.c index 9b4ede53a..462e89fe0 100644 --- a/wolfcrypt/src/wolfmath.c +++ b/wolfcrypt/src/wolfmath.c @@ -38,6 +38,7 @@ #include #include +#if defined(USE_FAST_MATH) || !defined(NO_BIG_INT) int get_digit_count(mp_int* a) { @@ -102,3 +103,5 @@ int mp_rand(mp_int* a, int digits, WC_RNG* rng) return ret; } + +#endif diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 47abf8238..eef73d019 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -150,6 +150,11 @@ #endif #endif +#ifndef CHAR_BIT + /* Needed for DTLS without big math */ + #include +#endif + #ifdef HAVE_LIBZ #include "zlib.h"