Skip to content
Merged
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
19 changes: 12 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ jobs:
- uses: actions/checkout@v3
- name: Build tinydtls
run: |
cmake -Dmake_tests=ON .
make
cmake -E make_directory build_test
cd build_test
cmake -DWARNING_TO_ERROR=ON -Dmake_tests=ON ..
cmake --build .
build-macos-cmake:
name: Build for macOS using CMake
runs-on: macos-latest
Expand All @@ -60,8 +62,10 @@ jobs:
- uses: actions/checkout@v3
- name: Build tinydtls
run: |
cmake -Dmake_tests=ON .
make
cmake -E make_directory build_test
cd build_test
cmake -DWARNING_TO_ERROR=ON -Dmake_tests=ON ..
cmake --build .

build-windows:
name: Build for Windows using CMake
Expand All @@ -71,6 +75,7 @@ jobs:
- uses: actions/checkout@v3
- name: Build tinydtls
run: |
cmake -G "Unix Makefiles" .
make

cmake -E make_directory build_test
cd build_test
cmake -G "Unix Makefiles" -DWARNING_TO_ERROR=ON ..
cmake --build .
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set(SOVERSION "0" )

option(DTLS_ECC "disable/enable support for TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" ON )
option(DTLS_PSK "disable/enable support for TLS_PSK_WITH_AES_128_CCM_8" ON)
option(WARNING_TO_ERROR "force all compiler warnings to be errors" OFF)

configure_file(dtls_config.h.cmake.in dtls_config.h )

Expand Down Expand Up @@ -67,8 +68,14 @@ target_compile_definitions(tinydtls PUBLIC DTLSv12 WITH_SHA256 SHA2_USE_INTTYPES
if(CMAKE_GENERATOR MATCHES "Visual Studio")
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Export all symbols when compiling to a .dll" ON)
target_compile_options(tinydtls PRIVATE -Wall)
if(${WARNING_TO_ERROR})
target_compile_options(tinydtls PRIVATE -WX)
endif()
elseif(NOT ZEPHYR_BASE)
target_compile_options(tinydtls PRIVATE -fPIC -pedantic -std=c99 -Wall -Wextra -Wformat-security -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wswitch-default -Wswitch-enum -Wunused)
if(${WARNING_TO_ERROR})
target_compile_options(tinydtls PRIVATE -Werror)
endif()
endif()

set_target_properties(tinydtls PROPERTIES VERSION ${PACKAGE_VERSION} SOVERSION ${SOVERSION})
Expand All @@ -83,6 +90,8 @@ else()
install(TARGETS tinydtls DESTINATION ${CMAKE_INSTALL_LIBDIR} )
endif()

file(CONFIGURE OUTPUT .gitignore
NEWLINE_STYLE UNIX
CONTENT "*")
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.18.0"))
file(CONFIGURE OUTPUT .gitignore
NEWLINE_STYLE UNIX
CONTENT "*")
endif()
2 changes: 1 addition & 1 deletion dtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ memarray_init(&dtlscontext_storage, dtlscontext_storage_data,
*/
#define CALL(Context, which, ...) \
((Context)->h && (Context)->h->which \
? (Context)->h->which((Context), ##__VA_ARGS__) \
? (Context)->h->which((Context), __VA_ARGS__) \
: -1)

static int
Expand Down
2 changes: 2 additions & 0 deletions sha2/sha2.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ static inline sha2_word64 get64be(const sha2_byte* data)
#endif /* BYTE_ORDER != LITTLE_ENDIAN */
}

#if defined(WITH_SHA512) || (defined(WITH_SHA384) && BYTE_ORDER == LITTLE_ENDIAN)
static inline void put64be(sha2_byte* data, sha2_word64 val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
Expand All @@ -239,6 +240,7 @@ static inline void put64be(sha2_byte* data, sha2_word64 val)
MEMCPY_BCOPY(data, &val, sizeof(val));
#endif /* BYTE_ORDER != LITTLE_ENDIAN */
}
#endif /* WITH_SHA512 || (WITH_SHA364 && BYTE_ORDER == LITTLE_ENDIAN) */

/*
* Macro for incrementally adding the unsigned 64-bit integer n to the
Expand Down
15 changes: 12 additions & 3 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ project(tinydtls-tests)

add_executable(dtls-server dtls-server.c)
target_link_libraries(dtls-server LINK_PUBLIC tinydtls)
target_compile_options(dtls-server PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
target_compile_options(dtls-server PUBLIC -Wall -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
if(${WARNING_TO_ERROR})
target_compile_options(dtls-server PUBLIC -Werror)
endif()

add_executable(ccm-test ccm-test.c)
target_link_libraries(ccm-test LINK_PUBLIC tinydtls)
target_compile_options(ccm-test PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
target_compile_options(ccm-test PUBLIC -Wall -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
if(${WARNING_TO_ERROR})
target_compile_options(ccm-test PUBLIC -Werror)
endif()

add_executable(dtls-client dtls-client.c)
target_link_libraries(dtls-client LINK_PUBLIC tinydtls)
target_compile_options(dtls-client PUBLIC -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
target_compile_options(dtls-client PUBLIC -Wall -DTEST_INCLUDE -DDTLSv12 -DWITH_SHA256)
if(${WARNING_TO_ERROR})
target_compile_options(dtls-client PUBLIC -Werror)
endif()