-
Notifications
You must be signed in to change notification settings - Fork 479
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 support #512
Merged
Merged
Mbedtls support #512
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
27a2b0d
Merge pull request #1 from cisco/master
ycyang1229 268eb50
add the mbedtls support.
ycyang1229 1e8aaa7
disable mbedtls.
ycyang1229 53e0746
add a mbedtls build to travis
pabuhler 5db3eed
use angle brackets for consistency.
ycyang1229 1c9b6bc
change the order of mbedtls.
ycyang1229 c134959
remove the wordy define.
ycyang1229 ad783d3
remove unnecessary parentheses.
ycyang1229 d7243eb
Merge branch 'master' into mbedtls-support
pabuhler 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 |
---|---|---|
|
@@ -4,7 +4,7 @@ project(libsrtp2 LANGUAGES C) | |
|
||
set(PACKAGE_VERSION 2.4.0) | ||
set(PACKAGE_STRING "${CMAKE_PROJECT_NAME} ${PACKAGE_VERSION}") | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_MODULE_PATH}") | ||
include(TestBigEndian) | ||
include(CheckIncludeFile) | ||
include(CheckFunctionExists) | ||
|
@@ -54,15 +54,27 @@ set(ENABLE_DEBUG_LOGGING OFF CACHE BOOL "Enable debug logging in all modules") | |
set(ERR_REPORTING_STDOUT OFF CACHE BOOL "Enable logging to stdout") | ||
set(ERR_REPORTING_FILE "" CACHE FILEPATH "Use file for logging") | ||
set(ENABLE_OPENSSL OFF CACHE BOOL "Enable OpenSSL crypto engine") | ||
set(ENABLE_MBEDTLS OFF CACHE BOOL "Enable MbedTLS crypto engine") | ||
set(TEST_APPS ON CACHE BOOL "Build test applications") | ||
option(BUILD_SHARED_LIBS "Build shared library" OFF) | ||
|
||
if(ENABLE_OPENSSL AND ENABLE_MBEDTLS) | ||
message(FATAL_ERROR "ssl conflict. can not enable openssl and mbedtls simultaneously.") | ||
endif() | ||
|
||
if(ENABLE_OPENSSL) | ||
find_package(OpenSSL REQUIRED) | ||
include_directories(${OPENSSL_INCLUDE_DIR}) | ||
set(OPENSSL ${ENABLE_OPENSSL} CACHE BOOL INTERNAL) | ||
set(GCM ${ENABLE_OPENSSL} CACHE BOOL INTERNAL) | ||
endif() | ||
|
||
if(ENABLE_MBEDTLS) | ||
find_package(MbedTLS REQUIRED) | ||
include_directories(${MBEDTLS_INCLUDE_DIRS}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same reason as the above stuff, FindMbedTLS.cmake. |
||
set(MBEDTLS ${ENABLE_MBEDTLS} CACHE BOOL INTERNAL) | ||
set(GCM ${ENABLE_MBEDTLS} CACHE BOOL INTERNAL) | ||
endif() | ||
set(OPENSSL ${ENABLE_OPENSSL} CACHE BOOL INTERNAL) | ||
set(GCM ${ENABLE_OPENSSL} CACHE BOOL INTERNAL) | ||
|
||
set(CONFIG_FILE_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
include_directories(${CONFIG_FILE_DIR}) | ||
|
@@ -85,6 +97,11 @@ if(ENABLE_OPENSSL) | |
crypto/cipher/aes_icm_ossl.c | ||
crypto/cipher/aes_gcm_ossl.c | ||
) | ||
elseif(ENABLE_MBEDTLS) | ||
list(APPEND CIPHERS_SOURCES_C | ||
crypto/cipher/aes_icm_mbedtls.c | ||
crypto/cipher/aes_gcm_mbedtls.c | ||
) | ||
else() | ||
list(APPEND CIPHERS_SOURCES_C | ||
crypto/cipher/aes.c | ||
|
@@ -101,6 +118,10 @@ if(ENABLE_OPENSSL) | |
list(APPEND HASHES_SOURCES_C | ||
crypto/hash/hmac_ossl.c | ||
) | ||
elseif(ENABLE_MBEDTLS) | ||
list(APPEND HASHES_SOURCES_C | ||
crypto/hash/hmac_mbedtls.c | ||
) | ||
else() | ||
list(APPEND HASHES_SOURCES_C | ||
crypto/hash/hmac.c | ||
|
@@ -182,6 +203,9 @@ target_include_directories(srtp2 PUBLIC crypto/include include) | |
if(ENABLE_OPENSSL) | ||
target_link_libraries(srtp2 OpenSSL::Crypto) | ||
endif() | ||
if(ENABLE_MBEDTLS) | ||
target_link_libraries(srtp2 ${MBEDTLS_LIBRARIES}) | ||
endif() | ||
if(WIN32) | ||
target_link_libraries(srtp2 ws2_32) | ||
target_compile_definitions(srtp2 PUBLIC _CRT_SECURE_NO_WARNINGS) | ||
|
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,38 @@ | ||
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) | ||
|
||
find_library(MBEDTLS_LIBRARY mbedtls) | ||
find_library(MBEDX509_LIBRARY mbedx509) | ||
find_library(MBEDCRYPTO_LIBRARY mbedcrypto) | ||
|
||
set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(MbedTLS DEFAULT_MSG | ||
MBEDTLS_LIBRARY MBEDTLS_INCLUDE_DIRS MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) | ||
|
||
mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) | ||
|
||
if(NOT TARGET MbedTLS) | ||
message("in mbedtls ${MBEDTLS_LIBRARY}") | ||
add_library(MbedTLS UNKNOWN IMPORTED) | ||
set_target_properties(MbedTLS PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${MBEDTLS_LIBRARY}") | ||
endif() | ||
|
||
if(NOT TARGET MbedCrypto) | ||
add_library(MbedCrypto UNKNOWN IMPORTED) | ||
set_target_properties(MbedCrypto PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${MBEDCRYPTO_LIBRARY}") | ||
endif() | ||
|
||
if(NOT TARGET MbedX509) | ||
add_library(MbedX509 UNKNOWN IMPORTED) | ||
set_target_properties(MbedX509 PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${MBEDTLS_INCLUDE_DIRS}" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${MBEDX509_LIBRARY}") | ||
endif() |
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
Oops, something went wrong.
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.
This seems unfortunate. What module are we finding from within the source tree?
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.
I added this for looking for FindMbedTLS.cmake, and it will be used for searching mbedtls related header files and libs. As I remember, I need to use such a cmake files to search mbedtls related stuff. Did I mistake it?