Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mbedtls: fix compilation error for host-generic builds #74

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mbedtls/patches/02_rename_debug_var.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/programs/ssl/ssl_context_info.c mbedtls-2.28.0-phoenix/programs/ssl/ssl_context_info.c
--- mbedtls-2.28.0/programs/ssl/ssl_context_info.c 2022-05-12 15:49:04.327065471 +0200
+++ mbedtls-2.28.0-phoenix/programs/ssl/ssl_context_info.c 2022-05-12 15:44:21.216459932 +0200
diff -ur '--exclude=*.git' mbedtls-2.28.0/programs/ssl/ssl_context_info.c mbedtls-2.28.0-phx/programs/ssl/ssl_context_info.c
--- mbedtls-2.28.0/programs/ssl/ssl_context_info.c 2021-12-15 14:47:54.000000000 +0100
+++ mbedtls-2.28.0-phx/programs/ssl/ssl_context_info.c 2024-03-22 13:15:45.658210852 +0100
@@ -118,7 +118,8 @@
FILE *b64_file = NULL; /* file with base64 codes to deserialize */
char conf_keep_peer_certificate = 1; /* MBEDTLS_SSL_KEEP_PEER_CERTIFICATE from mbedTLS configuration */
char conf_dtls_proto = 1; /* MBEDTLS_SSL_PROTO_DTLS from mbedTLS configuration */
-char debug = 0; /* flag for debug messages */
+/* 'debug' has been already defined as syscall in Phoenix-RTOS */
+static char debug = 0; /* flag for debug messages */
+static char debug = 0; /* flag for debug messages */
const char alloc_err[] = "Cannot allocate memory\n";
const char buf_ln_err[] = "Buffer does not have enough data to complete the parsing\n";

53 changes: 25 additions & 28 deletions mbedtls/patches/04_set_devrandom_entropy.patch
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/include/mbedtls/config.h mbedtls-2.28.0-phoenix/include/mbedtls/config.h
--- mbedtls-2.28.0/include/mbedtls/config.h 2022-06-03 16:51:07.159240599 +0200
+++ mbedtls-2.28.0-phoenix/include/mbedtls/config.h 2022-06-03 16:14:49.552991553 +0200
@@ -566,6 +566,16 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/include/mbedtls/config.h mbedtls-2.28.0-phx/include/mbedtls/config.h
--- mbedtls-2.28.0/include/mbedtls/config.h 2021-12-15 14:47:54.000000000 +0100
+++ mbedtls-2.28.0-phx/include/mbedtls/config.h 2024-03-22 12:55:15.422897117 +0100
@@ -565,6 +565,18 @@
*/
//#define MBEDTLS_ENTROPY_HARDWARE_ALT

/**
+#if defined(phoenix)
+/**
+ * \def MBEDTLS_ENTROPY_DEV_RANDOM
+ *
+ *
+ * Uncomment this macro to let mbed TLS use /dev/random as entropy source.
+ *
+ *
+ * If /dev/random is not present in file system it will not be used.
+ *
+ *
+ */
+#define MBEDTLS_ENTROPY_DEV_RANDOM
+#endif
+
+/**
/**
* \def MBEDTLS_AES_ROM_TABLES
*
* Use precomputed AES tables stored in ROM.
diff -ur '--exclude=*.git' mbedtls-2.28.0/include/mbedtls/entropy_poll.h mbedtls-2.28.0-phoenix/include/mbedtls/entropy_poll.h
--- mbedtls-2.28.0/include/mbedtls/entropy_poll.h 2022-06-03 16:51:07.167240769 +0200
+++ mbedtls-2.28.0-phoenix/include/mbedtls/entropy_poll.h 2022-06-03 16:14:49.556991637 +0200
@@ -91,6 +91,13 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/include/mbedtls/entropy_poll.h mbedtls-2.28.0-phx/include/mbedtls/entropy_poll.h
--- mbedtls-2.28.0/include/mbedtls/entropy_poll.h 2021-12-15 14:47:54.000000000 +0100
+++ mbedtls-2.28.0-phx/include/mbedtls/entropy_poll.h 2024-03-22 12:54:42.299296164 +0100
@@ -91,6 +91,11 @@
unsigned char *output, size_t len, size_t *olen );
#endif

+#if defined(phoenix)
+#if defined(MBEDTLS_ENTROPY_DEV_RANDOM)
+int mbedtls_devrandom_poll( void *data, unsigned char *output,
+ size_t len, size_t *olen );
+#endif
+#endif
+
#if defined(MBEDTLS_ENTROPY_NV_SEED)
/**
* \brief Entropy poll callback for a non-volatile seed file
diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy.c mbedtls-2.28.0-phoenix/library/entropy.c
--- mbedtls-2.28.0/library/entropy.c 2022-06-03 16:51:07.223241958 +0200
+++ mbedtls-2.28.0-phoenix/library/entropy.c 2022-06-03 16:14:49.600992572 +0200
@@ -111,6 +110,17 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy.c mbedtls-2.28.0-phx/library/entropy.c
--- mbedtls-2.28.0/library/entropy.c 2021-12-15 14:47:54.000000000 +0100
+++ mbedtls-2.28.0-phx/library/entropy.c 2024-03-22 12:48:05.811392714 +0100
@@ -111,6 +111,17 @@
MBEDTLS_ENTROPY_SOURCE_STRONG );
ctx->initial_entropy_run = 0;
#endif
Expand All @@ -56,15 +56,13 @@ diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy.c mbedtls-2.28.0-phoen
#endif /* MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES */
}

Binary files mbedtls-2.28.0/library/entropy.o and mbedtls-2.28.0-phoenix/library/entropy.o differ
diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy_poll.c mbedtls-2.28.0-phoenix/library/entropy_poll.c
--- mbedtls-2.28.0/library/entropy_poll.c 2022-06-03 16:51:07.227242043 +0200
+++ mbedtls-2.28.0-phoenix/library/entropy_poll.c 2022-06-03 16:48:32.243950552 +0200
@@ -50,6 +50,42 @@
diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy_poll.c mbedtls-2.28.0-phx/library/entropy_poll.c
--- mbedtls-2.28.0/library/entropy_poll.c 2021-12-15 14:47:54.000000000 +0100
+++ mbedtls-2.28.0-phx/library/entropy_poll.c 2024-03-22 12:54:48.199226275 +0100
@@ -50,6 +50,40 @@
#error "Platform entropy sources only work on Unix and Windows, see MBEDTLS_NO_PLATFORM_ENTROPY in config.h"
#endif

+#if defined(phoenix)
+#if defined(MBEDTLS_ENTROPY_DEV_RANDOM)
+
+#include <stdio.h>
Expand All @@ -85,7 +83,7 @@ diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy_poll.c mbedtls-2.28.0-
+ return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
+
+ ret = fread( p, 1, len, file );
+ if( ret == 0 && ferror( file ) )
+ if( ret == 0 && ferror( file ) )
+ {
+ fclose( file );
+ return( MBEDTLS_ERR_ENTROPY_SOURCE_FAILED );
Expand All @@ -98,7 +96,6 @@ diff -ur '--exclude=*.git' mbedtls-2.28.0/library/entropy_poll.c mbedtls-2.28.0-
+}
+
+#endif
+#endif
+
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)

Expand Down
Loading