-
Notifications
You must be signed in to change notification settings - Fork 107
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
[ssl] Migrate to mbedtls 3 #290
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
622e91c
[ssl] Add mbedtls 3 compatibility
tobil4sk f3c8dba
[ci] Use mbedtls3 for dynamic mac build
tobil4sk d2ffb9c
[cmake] Update to mbedtls 3.6 for static builds
tobil4sk 804f3c2
[ssl] Initialize PSA crypto when it is present.
Apprentice-Alchemist 47d72ff
[ci] Build on ubuntu bionic instead of xenial
tobil4sk 4e58a82
[ssl] Fix mbedtls compilation errors on windows
tobil4sk 69c13f5
[ssl] Link bcrypt on windows
tobil4sk 9010629
[ssl] Define mbedtls config file when compiling ssl.c
tobil4sk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,5 @@ | ||
# Apply config adjustments similer to Debian's | ||
# https://anonscm.debian.org/cgit/collab-maint/mbedtls.git/tree/debian/patches/01_config.patch | ||
|
||
set(config ${MbedTLS_source}/include/mbedtls/config.h) | ||
|
||
file(READ ${config} content) | ||
|
||
if (WIN32) | ||
# allow alternate threading implementation | ||
string(REPLACE | ||
"//#define MBEDTLS_THREADING_ALT" | ||
"#define MBEDTLS_THREADING_ALT" | ||
content "${content}" | ||
) | ||
# disable the TCP/IP networking routines | ||
# such that it wouldn't interfere with the #include <windows.h> in our threading_alt.h | ||
string(REPLACE | ||
"#define MBEDTLS_NET_C" | ||
"//#define MBEDTLS_NET_C" | ||
content "${content}" | ||
) | ||
|
||
file(COPY ${source}/libs/ssl/threading_alt.h | ||
DESTINATION ${MbedTLS_source}/include/mbedtls/ | ||
) | ||
else() | ||
# enable pthread mutexes | ||
string(REPLACE | ||
"//#define MBEDTLS_THREADING_PTHREAD" | ||
"#define MBEDTLS_THREADING_PTHREAD" | ||
content "${content}" | ||
) | ||
endif() | ||
|
||
# enable the HAVEGE random generator | ||
string(REPLACE | ||
"//#define MBEDTLS_HAVEGE_C" | ||
"#define MBEDTLS_HAVEGE_C" | ||
content "${content}" | ||
) | ||
# enable support for (rare) MD2-signed X.509 certs | ||
string(REPLACE | ||
"//#define MBEDTLS_MD2_C" | ||
"#define MBEDTLS_MD2_C" | ||
content "${content}" | ||
) | ||
# enable support for (rare) MD4-signed X.509 certs | ||
string(REPLACE | ||
"//#define MBEDTLS_MD4_C" | ||
"#define MBEDTLS_MD4_C" | ||
content "${content}" | ||
) | ||
# allow use of mutexes within mbed TLS | ||
string(REPLACE | ||
"//#define MBEDTLS_THREADING_C" | ||
"#define MBEDTLS_THREADING_C" | ||
content "${content}" | ||
) | ||
|
||
file(WRITE ${config} "${content}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifdef _WIN32 | ||
#define MBEDTLS_THREADING_ALT | ||
#endif | ||
#ifndef _WIN32 | ||
#define MBEDTLS_THREADING_PTHREAD | ||
#endif | ||
|
||
#undef MBEDTLS_NET_C | ||
|
||
#define MBEDTLS_THREADING_C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#define WIN32_LEAN_AND_MEAN | ||
#include <windows.h> | ||
|
||
typedef struct | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I thought this define was to exclude some things. How does this "fix" anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on after including
threading_alt.h
, mbedtls files go on to include other headers (presumablywinsock2.h
). But since the fullwindows.h
has already been included, this results in re-definitions and compilation errors. By settingWIN32_LEAN_AND_MEAN
, a lot of the unnecessary definitions are excluded fromwindows.h
which avoids these conflicts later on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I mean this is a good define to make regardless, I just find it strange that it's strictly necessary for compilation. But then again it probably won't matter. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just about the order of includes. Including
windows.h
inthreading_alt.h
like we do results in this ordering, which breaks compilation:Since at the time when
windows.h
is included we haven't includedwinsock2.h
yet,windows.h
includeswinsock.h
instead which contains conflicting definitions. Then whenwinsock2.h
is included we get redefinition errors.If
WIN32_LEAN_AND_MEAN
is defined, thenwinsock.h
is excluded fromwindows.h
so we don't end up with these redefinition errors when includingwinsock2.h
.More details here: https://stackoverflow.com/questions/21399650/cannot-include-both-files-winsock2-windows-h