diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1c61c49..c237f9dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,8 @@ jobs: CC: ["gcc", "clang" ] steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: setup run: | sudo apt-get update && sudo apt-get install -y libcunit1-dev libtool libtool-bin exuberant-ctags valgrind @@ -48,6 +50,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Build tinydtls run: | cmake -E make_directory build_test @@ -60,6 +64,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Build tinydtls run: | cmake -E make_directory build_test @@ -73,6 +79,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: recursive - name: Build tinydtls run: | cmake -E make_directory build_test diff --git a/CMakeLists.txt b/CMakeLists.txt index 551282f1..97701b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,11 +70,13 @@ target_sources(tinydtls PRIVATE aes/rijndael.c aes/rijndael_wrap.c sha2/sha2.c - ecc/ecc.c) + ext/micro-ecc/uECC.c) -target_include_directories(tinydtls PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(tinydtls PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/ext/micro-ecc ) target_compile_definitions(tinydtls PUBLIC DTLSv12 WITH_SHA256 SHA2_USE_INTTYPES_H DTLS_CHECK_CONTENTTYPE) +set_source_files_properties(ext/micro-ecc/uECC.c PROPERTIES COMPILE_OPTIONS "-Wno-pedantic;-Wno-unused-parameter;-Wno-missing-prototypes;-Wno-missing-declarations") + 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) diff --git a/crypto.c b/crypto.c index 1fe0807b..4a4ccc58 100644 --- a/crypto.c +++ b/crypto.c @@ -610,9 +610,10 @@ dtls_ecdsa_verify_sig_hash(const unsigned char *pub_key_x, unsigned char *result_r, unsigned char *result_s) { const dtls_ecdh_curve curve = default_curve; uint8_t pub_key[2 * DTLS_EC_KEY_SIZE]; + assert(sizeof(pub_key) >= (key_size * 2)); memcpy(pub_key, pub_key_x, key_size); memcpy(pub_key + key_size, pub_key_y, key_size); - return dtls_ecdsa_verify_sig_hash2(pub_key, key_size, + return dtls_ecdsa_verify_sig_hash2(pub_key, sizeof(pub_key), sign_hash, sign_hash_size, curve, result_r, result_s); @@ -634,7 +635,6 @@ dtls_ecdsa_verify_sig_hash2(const unsigned char *pub_key, size_t key_size, (void)result_s; curve_size = uECC_curve_public_key_size(uecc_curve); - assert(key_size == (unsigned int)curve_size); assert(sizeof(sign) >= (unsigned int)curve_size);