From 351c71b7f266266314cc34b67f2877d5e69fa11f Mon Sep 17 00:00:00 2001
From: Dave Rodgman <dave.rodgman@arm.com>
Date: Mon, 6 Dec 2021 17:50:53 +0000
Subject: [PATCH] Fix builds when config.h only defines MBEDTLS_BIGNUM_C

Fixes #4929

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
---
 include/mbedtls/entropy.h | 2 +-
 library/bignum.c          | 1 +
 programs/fuzz/common.c    | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/mbedtls/entropy.h b/include/mbedtls/entropy.h
index 128ec82529..fede05ffa1 100644
--- a/include/mbedtls/entropy.h
+++ b/include/mbedtls/entropy.h
@@ -124,7 +124,7 @@ typedef struct mbedtls_entropy_context
                               * -1 after free. */
 #if defined(MBEDTLS_ENTROPY_SHA512_ACCUMULATOR)
     mbedtls_sha512_context  MBEDTLS_PRIVATE(accumulator);
-#else
+#elif defined(MBEDTLS_ENTROPY_SHA256_ACCUMULATOR)
     mbedtls_sha256_context  MBEDTLS_PRIVATE(accumulator);
 #endif
     int             MBEDTLS_PRIVATE(source_count); /* Number of entries used in source. */
diff --git a/library/bignum.c b/library/bignum.c
index fdf8c9a42c..e47e25917d 100644
--- a/library/bignum.c
+++ b/library/bignum.c
@@ -43,6 +43,7 @@
 #include "mbedtls/error.h"
 #include "constant_time_internal.h"
 
+#include <limits.h>
 #include <string.h>
 
 #if defined(MBEDTLS_PLATFORM_C)
diff --git a/programs/fuzz/common.c b/programs/fuzz/common.c
index ac39ee22f3..e12ee3b8a0 100644
--- a/programs/fuzz/common.c
+++ b/programs/fuzz/common.c
@@ -1,4 +1,5 @@
 #include "common.h"
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>