Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package bctoolbox for openSUSE:Factory checked in at 2024-11-12 19:21:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/bctoolbox (Old) and /work/SRC/openSUSE:Factory/.bctoolbox.new.2017 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "bctoolbox" Tue Nov 12 19:21:15 2024 rev:51 rq:1223420 version:5.3.95 Changes: -------- --- /work/SRC/openSUSE:Factory/bctoolbox/bctoolbox.changes 2024-04-09 16:50:30.975348330 +0200 +++ /work/SRC/openSUSE:Factory/.bctoolbox.new.2017/bctoolbox.changes 2024-11-12 19:21:59.948921345 +0100 @@ -1,0 +2,10 @@ +Mon Nov 11 08:29:01 UTC 2024 - ecsos <[email protected]> + +- Update to 5.3.95 (no changelog). + +------------------------------------------------------------------- +Sun Oct 13 08:39:20 UTC 2024 - ecsos <[email protected]> + +- Update to 5.3.89 (no changelog). + +------------------------------------------------------------------- Old: ---- bctoolbox-5.3.37.tar.bz2 New: ---- bctoolbox-5.3.95.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ bctoolbox.spec ++++++ --- /var/tmp/diff_new_pack.ukEiF0/_old 2024-11-12 19:22:00.500944445 +0100 +++ /var/tmp/diff_new_pack.ukEiF0/_new 2024-11-12 19:22:00.504944612 +0100 @@ -18,7 +18,7 @@ %define sover 1 Name: bctoolbox -Version: 5.3.37 +Version: 5.3.95 Release: 0 Summary: Utility library for software from Belledonne Communications License: GPL-3.0-or-later @@ -37,9 +37,14 @@ BuildRequires: chrpath BuildRequires: cmake >= 3.22 BuildRequires: gcc-c++ -BuildRequires: mbedtls-devel BuildRequires: pkgconfig BuildRequires: pkgconfig(bcunit) >= 5.3.0 +%if 0%{?suse_version} > 1600 +BuildRequires: pkgconfig(mbedtls) < 3.0.0 +BuildRequires: pkgconfig(mbedtls) >= 2.0.0 +%else +BuildRequires: mbedtls-devel +%endif BuildRequires: pkgconfig(zlib) %description ++++++ bctoolbox-5.3.37.tar.bz2 -> bctoolbox-5.3.95.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/CHANGELOG.md new/bctoolbox-5.3.95/CHANGELOG.md --- old/bctoolbox-5.3.37/CHANGELOG.md 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/CHANGELOG.md 2024-09-18 21:36:16.000000000 +0200 @@ -9,6 +9,11 @@ - Crypto: remove polarssl support +## [5.3.68] - 2024-07-10 + +## Added +- Use locale encoding from setlocale() on Windows and fallback to CP_APC if not found. + ## [5.2.0] - 2022-11-14 ## Added diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/cmake/FindMbedTLS.cmake new/bctoolbox-5.3.95/cmake/FindMbedTLS.cmake --- old/bctoolbox-5.3.37/cmake/FindMbedTLS.cmake 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/cmake/FindMbedTLS.cmake 2024-09-18 21:36:16.000000000 +0200 @@ -55,10 +55,16 @@ set(MbedTLS_TARGET mbedtls) set(MbedX509_TARGET mbedx509) set(MbedCrypto_TARGET mbedcrypto) - set(MbedTLS_VERSION 3) - # We are building mbedTLS, we have DTLS-SRTP support - set(DTLS_SRTP_AVAILABLE ON) + get_target_property(MbedTLS_VERSION mbedtls VERSION) + if (MbedTLS_VERSION EQUAL "MbedTLS_VERSION-NOTFOUND") + set(MbedTLS_VERSION 3) + else() + string(REPLACE "." ";" MbedTLS_VERSION "${MbedTLS_VERSION}") + list(GET MbedTLS_VERSION 0 MbedTLS_VERSION) + # We are building mbedTLS, we have DTLS-SRTP support + set(DTLS_SRTP_AVAILABLE ON) + endif() else() include(CMakePushCheckState) @@ -94,7 +100,7 @@ message("MESSAGE: MbedTLS_LIBRARY=" ${_MbedTLS_LIBRARY}) message("MESSAGE: MbedX509_LIBRARY=" ${MbedX509_LIBRARY}) message("MESSAGE: MbedCrypto_LIBRARY=" ${MbedCrypto_LIBRARY}) - set(_MbedTLS_VERSION 1) + set(MbedTLS_VERSION 1) else() # Are we mbdetls 2 or 3? # From version 3 and on, version number is given in include/mbedtls/build_info.h. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/include/bctoolbox/charconv.h new/bctoolbox-5.3.95/include/bctoolbox/charconv.h --- old/bctoolbox-5.3.37/include/bctoolbox/charconv.h 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/include/bctoolbox/charconv.h 2024-09-18 21:36:16.000000000 +0200 @@ -29,9 +29,11 @@ /** * @brief Set the default encoding for the application. * + * @deprecated 2024/07/09: use setLocale() from <locale.h> to set the locale. On Windows, CP_APC will be used as + * default. * @param[in] encoding default encoding, "locale" to set it to the system's locale */ -BCTBX_PUBLIC void bctbx_set_default_encoding(const char *encoding); +BCTBX_DEPRECATED BCTBX_PUBLIC void bctbx_set_default_encoding(const char *encoding); /** * @brief Return the default encoding for the application. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/include/bctoolbox/crypto.hh new/bctoolbox-5.3.95/include/bctoolbox/crypto.hh --- old/bctoolbox-5.3.37/include/bctoolbox/crypto.hh 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/include/bctoolbox/crypto.hh 2024-09-18 21:36:16.000000000 +0200 @@ -76,9 +76,8 @@ ~RNG(); private: - struct Impl; - std::unique_ptr<Impl> pImpl; - static std::unique_ptr<Impl> pImplClass; + struct Impl; /**< a subclass holding the RNG internal implementation */ + std::unique_ptr<Impl> pImpl; /**< pointer to the actual RNG implementation */ }; // class RNG /*****************************************************************************/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/include/bctoolbox/logging.h new/bctoolbox-5.3.95/include/bctoolbox/logging.h --- old/bctoolbox-5.3.37/include/bctoolbox/logging.h 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/include/bctoolbox/logging.h 2024-09-18 21:36:16.000000000 +0200 @@ -74,13 +74,6 @@ BCTBX_PUBLIC void bctbx_uninit_logger(void); /* - Default functions to free log handlers - @param[in] bctbx_log_handler_t* handler : the handler to free -*/ -BCTBX_PUBLIC void bctbx_logv_out_destroy(bctbx_log_handler_t *handler); -BCTBX_PUBLIC void bctbx_logv_file_destroy(bctbx_log_handler_t *handler); - -/* Function to create a log handler @param[in] BctbxLogHandlerFunc func : the function to call to handle a new line of log @param[in] BctbxLogHandlerDestroyFunc destroy : the function to call to free this handler particuler its user_info diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/CMakeLists.txt new/bctoolbox-5.3.95/src/CMakeLists.txt --- old/bctoolbox-5.3.37/src/CMakeLists.txt 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/CMakeLists.txt 2024-09-18 21:36:16.000000000 +0200 @@ -104,7 +104,7 @@ # Fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105616 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 - AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 14) + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 15) set_source_files_properties(utils/regex.cc PROPERTIES COMPILE_OPTIONS "-Wno-error=maybe-uninitialized") endif() @@ -143,30 +143,22 @@ endif() target_compile_definitions(bctoolbox PRIVATE "BCTBX_EXPORTS") if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") # Fix error on 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker'' - get_target_property(BC_LINK_FLAGS bctoolbox LINK_FLAGS) - if(NOT BC_LINK_FLAGS) - set(BC_LINK_FLAGS "") - endif() - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - list(APPEND BC_LINK_FLAGS "/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib") - else() - list(APPEND BC_LINK_FLAGS "/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib") - endif() + list(APPEND BC_LINK_OPTIONS_DEBUG "/nodefaultlib:vccorlibd" "/nodefaultlib:msvcrtd" "vccorlibd.lib" "msvcrtd.lib") + list(APPEND BC_LINK_OPTIONS_RELEASE "/nodefaultlib:vccorlib" "/nodefaultlib:msvcrt" "vccorlib.lib" "msvcrt.lib") + target_link_options(bctoolbox PUBLIC "$<IF:$<CONFIG:Debug>,${BC_LINK_OPTIONS_DEBUG},${BC_LINK_OPTIONS_RELEASE}>") if(MSVC) set_target_properties(bctoolbox PROPERTIES VS_WINRT_COMPONENT TRUE) else() target_compile_options(bctoolbox PRIVATE -ZW -EHsc) endif() - set_target_properties(bctoolbox PROPERTIES LINK_FLAGS "${BC_LINK_FLAGS}") endif() endif() if(MSVC AND BUILD_SHARED_LIBS) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - install(FILES $<TARGET_PDB_FILE:bctoolbox> - DESTINATION ${CMAKE_INSTALL_BINDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) - endif() + install(FILES $<TARGET_PDB_FILE:bctoolbox> + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + CONFIGURATIONS Debug RelWithDebInfo + ) endif() if(HAVE_LIBRT) @@ -209,23 +201,22 @@ set_target_properties(bctoolbox-tester PROPERTIES SOVERSION ${BCTOOLBOXTESTER_SO_VERSION}) endif() if(MSVC AND BUILD_SHARED_LIBS) - if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") - install(FILES $<TARGET_PDB_FILE:bctoolbox-tester> - DESTINATION ${CMAKE_INSTALL_BINDIR} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - ) - endif() + install(FILES $<TARGET_PDB_FILE:bctoolbox-tester> + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + CONFIGURATIONS Debug RelWithDebInfo + ) endif() endif() if(APPLE AND IOS) add_library(bctoolbox-ios SHARED ${BCTOOLBOX_IOS_SOURCE_FILES}) target_link_libraries(bctoolbox-ios PRIVATE bctoolbox) + target_link_libraries(bctoolbox-ios PRIVATE "-framework UIKit" "-framework Foundation" "-framework CoreFoundation") set_target_properties(bctoolbox-ios PROPERTIES FRAMEWORK TRUE MACOSX_FRAMEWORK_IDENTIFIER org.linphone.bctoolbox-ios MACOSX_FRAMEWORK_INFO_PLIST "${PROJECT_SOURCE_DIR}/build/osx/Info.plist.in" - LINK_FLAGS "-framework UIKit -framework Foundation -framework CoreFoundation" ) endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/containers/list.c new/bctoolbox-5.3.95/src/containers/list.c --- old/bctoolbox-5.3.37/src/containers/list.c 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/containers/list.c 2024-09-18 21:36:16.000000000 +0200 @@ -206,7 +206,9 @@ bctbx_list_t *bctbx_list_unlink(bctbx_list_t *list, bctbx_list_t *elem) { bctbx_list_t *ret; - if (elem == list) { + if (!elem) { + return list; + } else if (elem == list) { ret = elem->next; elem->prev = NULL; elem->next = NULL; @@ -221,8 +223,13 @@ } bctbx_list_t *bctbx_list_erase_link(bctbx_list_t *list, bctbx_list_t *elem) { - bctbx_list_t *ret = bctbx_list_unlink(list, elem); - bctbx_free(elem); + bctbx_list_t *ret = NULL; + if (elem) { + ret = bctbx_list_unlink(list, elem); + bctbx_free(elem); + } else { + ret = list; + } return ret; } @@ -319,22 +326,32 @@ return list; } -bctbx_list_t *bctbx_list_copy(const bctbx_list_t *list) { +static bctbx_list_t *bctbx_list_copy_with_func(const bctbx_list_t *list, bctbx_list_copy_func copyfunc) { bctbx_list_t *copy = NULL; - const bctbx_list_t *iter; - for (iter = list; iter != NULL; iter = bctbx_list_next(iter)) { - copy = bctbx_list_append(copy, iter->data); + bctbx_list_t *prev = NULL; + + for (const bctbx_list_t *iter = list; iter != NULL; iter = bctbx_list_next(iter)) { + bctbx_list_t *item = bctbx_list_new(copyfunc ? copyfunc(iter->data) : iter->data); + + if (copy == NULL) { + copy = item; + } else { + prev->next = item; + item->prev = prev; + } + + prev = item; } + return copy; } +bctbx_list_t *bctbx_list_copy(const bctbx_list_t *list) { + return bctbx_list_copy_with_func(list, NULL); +} + bctbx_list_t *bctbx_list_copy_with_data(const bctbx_list_t *list, bctbx_list_copy_func copyfunc) { - bctbx_list_t *copy = NULL; - const bctbx_list_t *iter; - for (iter = list; iter != NULL; iter = bctbx_list_next(iter)) { - copy = bctbx_list_append(copy, copyfunc(iter->data)); - } - return copy; + return bctbx_list_copy_with_func(list, copyfunc); } bctbx_list_t *bctbx_list_copy_reverse_with_data(const bctbx_list_t *list, bctbx_list_copy_func copyfunc) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/conversion/charconv_windows.cc new/bctoolbox-5.3.95/src/conversion/charconv_windows.cc --- old/bctoolbox-5.3.37/src/conversion/charconv_windows.cc 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/conversion/charconv_windows.cc 2024-09-18 21:36:16.000000000 +0200 @@ -48,7 +48,8 @@ {"ISO-8859-8", 28598}, {"ISO-8859-9", 28599}, {"ISO-8859-13", 28603}, {"ISO-8859-15", 28605}, {"ISO-2022-JP", 50222}, {"CSISO2022JP", 50221}, {"ISO-2022-KR", 50225}, {"EUC-JP", 51932}, {"EUC-CN", 51936}, {"EUC-KR", 51949}, {"GB18030", 54936}, {"UTF-7", 65000}, - {"UTF-8", 65001}}; + {"UTF-8", 65001}, {"UTF7", 65000}, {"UTF8", 65001}, {"UTF16", 1200}, + {"UTF32", 12000}, {"UTF32BE", 12001}}; static std::string stringToUpper(const std::string &str) { std::string result(str.size(), ' '); @@ -67,8 +68,8 @@ UINT rFrom, rTo; try { - rFrom = windowsCharset.at(stringToUpper(std::string(from))); - rTo = windowsCharset.at(stringToUpper(std::string(to))); + rFrom = bctbx_get_code_page(from); + rTo = bctbx_get_code_page(to); } catch (const std::out_of_range &) { bctbx_error("Error while converting a string from '%s' to '%s': unknown charset", from, to); return NULL; @@ -140,10 +141,17 @@ unsigned int bctbx_get_code_page(const char *encoding) { unsigned int codePage = CP_ACP; std::string encodingStr; - if (!encoding || encoding[0] == '\0') encodingStr = bctbx_get_default_encoding(); - else encodingStr = encoding; + if (!encoding || encoding[0] == '\0') encodingStr = stringToUpper(bctbx_get_default_encoding()); + else encodingStr = stringToUpper(encoding); + if (encodingStr == "LOCALE") { + char *locale = setlocale(LC_CTYPE, NULL); + if (strstr(locale, ".") != NULL) { + // return codeset (last block of chars preceeded by a dot) + encodingStr = stringToUpper(strrchr(locale, '.') + 1); + } + } try { - codePage = windowsCharset.at(stringToUpper(encodingStr)); + codePage = windowsCharset.at(encodingStr); } catch (const std::out_of_range &) { bctbx_error("No code page found for '%s'. Using Locale.", encodingStr.c_str()); return CP_ACP; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/crypto/mbedtls-v2.c new/bctoolbox-5.3.95/src/crypto/mbedtls-v2.c --- old/bctoolbox-5.3.37/src/crypto/mbedtls-v2.c 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/crypto/mbedtls-v2.c 2024-09-18 21:36:16.000000000 +0200 @@ -100,8 +100,26 @@ int32_t bctbx_base64_decode(unsigned char *output, size_t *output_length, const unsigned char *input, size_t input_length) { size_t byte_written = 0; - int ret = mbedtls_base64_decode(output, *output_length, &byte_written, input, input_length); + size_t missingPaddingSize = 0; + unsigned char *paddedInput = NULL; + /* mbedtls function does not work well if the padding is omitted, restore it if needed */ + if ((input_length % 4) != 0) { + missingPaddingSize = 4 - (input_length % 4); + paddedInput = bctbx_malloc(input_length + 2); + memcpy(paddedInput, input, input_length); + if (missingPaddingSize > 0) { + paddedInput[input_length] = '='; + } + if (missingPaddingSize > 1) { + paddedInput[input_length + 1] = '='; + } + } + int ret = mbedtls_base64_decode(output, *output_length, &byte_written, + missingPaddingSize == 0 ? input : paddedInput, input_length + missingPaddingSize); *output_length = byte_written; + if (paddedInput != NULL) { + bctbx_free(paddedInput); + } if (ret == MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) { return BCTBX_ERROR_OUTPUT_BUFFER_TOO_SMALL; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/crypto/mbedtls.c new/bctoolbox-5.3.95/src/crypto/mbedtls.c --- old/bctoolbox-5.3.37/src/crypto/mbedtls.c 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/crypto/mbedtls.c 2024-09-18 21:36:16.000000000 +0200 @@ -100,8 +100,26 @@ int32_t bctbx_base64_decode(unsigned char *output, size_t *output_length, const unsigned char *input, size_t input_length) { size_t byte_written = 0; - int ret = mbedtls_base64_decode(output, *output_length, &byte_written, input, input_length); + size_t missingPaddingSize = 0; + unsigned char *paddedInput = NULL; + /* mbedtls function does not work well if the padding is omitted, restore it if needed */ + if ((input_length % 4) != 0) { + missingPaddingSize = 4 - (input_length % 4); + paddedInput = bctbx_malloc(input_length + 2); + memcpy(paddedInput, input, input_length); + if (missingPaddingSize > 0) { + paddedInput[input_length] = '='; + } + if (missingPaddingSize > 1) { + paddedInput[input_length + 1] = '='; + } + } + int ret = mbedtls_base64_decode(output, *output_length, &byte_written, + missingPaddingSize == 0 ? input : paddedInput, input_length + missingPaddingSize); *output_length = byte_written; + if (paddedInput != NULL) { + bctbx_free(paddedInput); + } if (ret == MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) { return BCTBX_ERROR_OUTPUT_BUFFER_TOO_SMALL; } @@ -888,6 +906,13 @@ int32_t bctbx_ssl_read(bctbx_ssl_context_t *ssl_ctx, unsigned char *buf, size_t buf_length) { int ret = mbedtls_ssl_read(&(ssl_ctx->ssl_ctx), buf, buf_length); + if (mbedtls_ssl_get_version_number(&(ssl_ctx->ssl_ctx)) == MBEDTLS_SSL_VERSION_TLS1_3) { + while (ret == MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET || + ssl_ctx->ssl_ctx.MBEDTLS_PRIVATE(state) == MBEDTLS_SSL_TLS1_3_NEW_SESSION_TICKET) { + bctbx_message("TLS got session ticket in TLS 1.3 connection, retry read"); + ret = mbedtls_ssl_read(&(ssl_ctx->ssl_ctx), buf, buf_length); + } + } /* remap some output code */ if (ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) { ret = BCTBX_ERROR_SSL_PEER_CLOSE_NOTIFY; @@ -1042,7 +1067,6 @@ #endif /* HAVE_DTLS_SRTP */ /** DTLS SRTP functions **/ - /** config **/ #ifdef HAVE_DTLS_SRTP typedef struct bctbx_dtls_srtp_keys { @@ -1080,6 +1104,9 @@ ssl_config->ssl_config_externally_provided = 0; mbedtls_ssl_config_init(ssl_config->ssl_config); + mbedtls_ssl_conf_session_tickets(ssl_config->ssl_config, MBEDTLS_SSL_SESSION_TICKETS_DISABLED); + mbedtls_ssl_conf_renegotiation(ssl_config->ssl_config, MBEDTLS_SSL_RENEGOTIATION_DISABLED); + ssl_config->callback_cli_cert_function = NULL; ssl_config->callback_cli_cert_data = NULL; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/crypto/mbedtls.cc new/bctoolbox-5.3.95/src/crypto/mbedtls.cc --- old/bctoolbox-5.3.37/src/crypto/mbedtls.cc 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/crypto/mbedtls.cc 2024-09-18 21:36:16.000000000 +0200 @@ -33,6 +33,14 @@ #include <mbedtls/hkdf.h> // HKDF implemented in version 2.11.0 of mbedtls #endif +#if MBEDTLS_VERSION_NUMBER >= 0x03060000 // v3.6.0 + // starting from version 3.6, use PSA crypto +#include "bctoolbox/logging.h" +#include <mutex> +#include <psa/crypto.h> +#define BCTBX_USE_MBEDTLS_PSA +#endif + #include "bctoolbox/crypto.hh" #include "bctoolbox/defs.h" #include "bctoolbox/exception.hh" @@ -52,14 +60,81 @@ namespace bctoolbox { +namespace { +#ifdef BCTBX_USE_MBEDTLS_PSA +// This is also defined in mbedtls source code by a custom modification +using mbedtls_threading_mutex_t = void *; + +void threading_mutex_init_cpp(mbedtls_threading_mutex_t *mutex) { + if (mutex == NULL) { + return; + } + auto m = new std::mutex(); + *mutex = (void *)m; +} + +void threading_mutex_free_cpp(mbedtls_threading_mutex_t *mutex) { + if (mutex == NULL) { + return; + } + delete (static_cast<std::mutex *>(*mutex)); +} + +int threading_mutex_lock_cpp(mbedtls_threading_mutex_t *mutex) { + if (mutex == NULL) { + return MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; + } + static_cast<std::mutex *>(*mutex)->lock(); + return 0; +} + +int threading_mutex_unlock_cpp(mbedtls_threading_mutex_t *mutex) { + if (mutex == NULL) { + return MBEDTLS_ERR_THREADING_BAD_INPUT_DATA; + } + static_cast<std::mutex *>(*mutex)->unlock(); + return 0; +} +#endif // BCTBX_USE_MBEDTLS_PSA + +class mbedtlsStaticContexts { +public: + void randomize(uint8_t *buffer, size_t size) { + sRNG->randomize(buffer, size); + } + + std::unique_ptr<RNG> sRNG; + mbedtlsStaticContexts() { +#ifdef BCTBX_USE_MBEDTLS_PSA + mbedtls_threading_set_alt(threading_mutex_init_cpp, threading_mutex_free_cpp, threading_mutex_lock_cpp, + threading_mutex_unlock_cpp); + if (psa_crypto_init() != PSA_SUCCESS) { + bctbx_error("MbedTLS PSA init fail"); + } +#endif // BCTBX_USE_MBEDTLS_PSA + // Now that mbedtls is ready, instanciate the static RNG + sRNG = std::make_unique<RNG>(); + } + ~mbedtlsStaticContexts() { + // before destroying mbedtls internal context, destroy the static RNG + sRNG = nullptr; +#ifdef BCTBX_USE_MBEDTLS_PSA + mbedtls_psa_crypto_free(); + mbedtls_threading_free_alt(); +#endif // BCTBX_USE_MBEDTLS_PSA + } +}; +static const auto mbedtlsStaticContextsInstance = std::make_unique<mbedtlsStaticContexts>(); +}; // namespace + /*****************************************************************************/ /*** Random Number Generation ***/ /*****************************************************************************/ - /** * @brief Wrapper around mbedtls implementation **/ struct RNG::Impl { + mbedtls_entropy_context entropy; /**< entropy context - store it to be able to free it */ mbedtls_ctr_drbg_context ctr_drbg; /**< rng context */ @@ -84,7 +159,7 @@ * Constructor * Just instanciate an implementation */ -RNG::RNG() : pImpl(std::unique_ptr<RNG::Impl>(new RNG::Impl())){}; +RNG::RNG() : pImpl(std::make_unique<RNG::Impl>()) {}; /** * Destructor @@ -92,9 +167,6 @@ **/ RNG::~RNG() = default; -// Instanciate the class RNG context -std::unique_ptr<RNG::Impl> RNG::pImplClass = std::unique_ptr<RNG::Impl>(new RNG::Impl()); - void RNG::randomize(uint8_t *buffer, size_t size) { int ret = mbedtls_ctr_drbg_random(&(pImpl->ctr_drbg), buffer, size); if (ret != 0) { @@ -126,12 +198,7 @@ * These use the class RNG context */ void RNG::cRandomize(uint8_t *buffer, size_t size) { - int ret = mbedtls_ctr_drbg_random(&(pImplClass->ctr_drbg), buffer, size); - if (ret != 0) { - throw BCTBX_EXCEPTION << ((ret == MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) - ? "RNG failure: Request too big" - : "RNG failure: entropy source failure"); - } + mbedtlsStaticContextsInstance->randomize(buffer, size); } uint32_t RNG::cRandomize() { @@ -140,47 +207,6 @@ return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3]; } -std::string encodeBase64(const std::vector<uint8_t> &input) { - size_t byteWritten = 0; - size_t outputLength = 0; - auto inputBuffer = input.data(); - size_t inputLength = input.size(); - mbedtls_base64_encode(nullptr, outputLength, &byteWritten, inputBuffer, - inputLength); // set encodedLength to the correct value - outputLength = byteWritten; - if (outputLength == 0) return std::string(); - unsigned char *outputBuffer = new unsigned char[outputLength]; // allocate encoded buffer with correct length - int ret = - mbedtls_base64_encode(outputBuffer, outputLength, &byteWritten, inputBuffer, inputLength); // real encoding - if (ret != 0) { - delete[] outputBuffer; - return std::string(); - } - std::string output((char *)outputBuffer); - delete[] outputBuffer; - return output; -} - -std::vector<uint8_t> decodeBase64(const std::string &input) { - size_t byteWritten = 0; - size_t outputLength = 0; - const unsigned char *inputBuffer = (const unsigned char *)input.data(); - size_t inputLength = input.size(); - mbedtls_base64_decode(nullptr, outputLength, &byteWritten, inputBuffer, - inputLength); // set decodedLength to the correct value - outputLength = byteWritten; - unsigned char *outputBuffer = new unsigned char[outputLength]; // allocate decoded buffer with correct length - int ret = - mbedtls_base64_decode(outputBuffer, outputLength, &byteWritten, inputBuffer, inputLength); // real decoding - if (ret != 0) { - delete[] outputBuffer; - return std::vector<uint8_t>(); - } - std::vector<uint8_t> output(outputBuffer, outputBuffer + outputLength); - delete[] outputBuffer; - return output; -} - /*****************************************************************************/ /*** Hash related function ***/ /*****************************************************************************/ @@ -712,6 +738,62 @@ return 0; } +std::string encodeBase64(const std::vector<uint8_t> &input) { + size_t byteWritten = 0; + size_t outputLength = 0; + auto inputBuffer = input.data(); + size_t inputLength = input.size(); + mbedtls_base64_encode(nullptr, outputLength, &byteWritten, inputBuffer, + inputLength); // set encodedLength to the correct value + outputLength = byteWritten; + if (outputLength == 0) return std::string(); + unsigned char *outputBuffer = new unsigned char[outputLength]; // allocate encoded buffer with correct length + int ret = + mbedtls_base64_encode(outputBuffer, outputLength, &byteWritten, inputBuffer, inputLength); // real encoding + if (ret != 0) { + delete[] outputBuffer; + return std::string(); + } + std::string output((char *)outputBuffer); + delete[] outputBuffer; + return output; +} + +std::vector<uint8_t> decodeBase64(const std::string &input) { + + size_t missingPaddingSize = 0; + std::string paddedInput{}; + // mbedtls function does not work well if the padding is omitted, restore it if needed + if ((input.size() % 4) != 0) { + missingPaddingSize = 4 - (input.size() % 4); + paddedInput = input; + if (missingPaddingSize == 1) { + paddedInput.append("="); + } + if (missingPaddingSize == 2) { + paddedInput.append("=="); + } + } + size_t byteWritten = 0; + size_t outputLength = 0; + const unsigned char *inputBuffer = + (missingPaddingSize == 0) ? (const unsigned char *)input.data() : (const unsigned char *)paddedInput.data(); + size_t inputLength = input.size() + missingPaddingSize; + mbedtls_base64_decode(nullptr, outputLength, &byteWritten, inputBuffer, + inputLength); // set decodedLength to the correct value + outputLength = byteWritten; + unsigned char *outputBuffer = new unsigned char[outputLength]; // allocate decoded buffer with correct length + int ret = + mbedtls_base64_decode(outputBuffer, outputLength, &byteWritten, inputBuffer, inputLength); // real decoding + if (ret != 0) { + delete[] outputBuffer; + return std::vector<uint8_t>(); + } + std::vector<uint8_t> output(outputBuffer, outputBuffer + outputLength); + delete[] outputBuffer; + return output; +} + } // namespace bctoolbox /*** Random Number Generation: C API ***/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/logging/logging.c new/bctoolbox-5.3.95/src/logging/logging.c --- old/bctoolbox-5.3.37/src/logging/logging.c 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/logging/logging.c 2024-09-18 21:36:16.000000000 +0200 @@ -134,13 +134,17 @@ if (func) func(domain, lev, fmt, args); } +static void bctbx_handler_uninit(bctbx_log_handler_t *handler); +static void bctbx_handler_logv_file_uninit(bctbx_log_handler_t *handler); +static void bctbx_handler_logv_file_destroy(bctbx_log_handler_t *handler); + static bctbx_logger_t main_logger = {0}; static bctbx_log_handler_t static_handler = {0}; static void initialize_default_handler(void) { main_logger.default_handler = &static_handler; static_handler.func = wrapper; - static_handler.destroy = (BctbxLogHandlerDestroyFunc)bctbx_logv_out_destroy; + static_handler.destroy = (BctbxLogHandlerDestroyFunc)bctbx_handler_uninit; static_handler.user_info = (void *)bctbx_logv_out; bctbx_add_log_handler(&static_handler); } @@ -236,7 +240,7 @@ handler = bctbx_new0(bctbx_log_handler_t, 1); handler->func = bctbx_logv_file; - handler->destroy = bctbx_logv_file_destroy; + handler->destroy = bctbx_handler_logv_file_destroy; handler->user_info = filehandler; end: @@ -287,10 +291,10 @@ } void bctbx_set_log_file(FILE *f) { - static bctbx_file_log_handler_t filehandler; - static bctbx_log_handler_t handler; + static bctbx_file_log_handler_t filehandler = {0}; + static bctbx_log_handler_t handler = {0}; handler.func = bctbx_logv_file; - handler.destroy = (BctbxLogHandlerDestroyFunc)bctbx_logv_file_destroy; + handler.destroy = (BctbxLogHandlerDestroyFunc)bctbx_handler_logv_file_uninit; filehandler.max_size = -1; filehandler.file = f; handler.user_info = (void *)&filehandler; @@ -655,7 +659,7 @@ if (tags) bctbx_free(tags); } -void bctbx_logv_out_destroy(bctbx_log_handler_t *handler) { +static void bctbx_handler_uninit(bctbx_log_handler_t *handler) { handler->user_info = NULL; } @@ -830,12 +834,20 @@ if (msg) bctbx_free(msg); } -void bctbx_logv_file_destroy(bctbx_log_handler_t *handler) { +static void bctbx_handler_logv_file_uninit(bctbx_log_handler_t *handler) { bctbx_file_log_handler_t *filehandler = (bctbx_file_log_handler_t *)handler->user_info; fclose(filehandler->file); bctbx_free(filehandler->path); bctbx_free(filehandler->name); - bctbx_logv_out_destroy(handler); + bctbx_handler_uninit(handler); +} + +static void bctbx_handler_logv_file_destroy(bctbx_log_handler_t *handler) { + bctbx_file_log_handler_t *filehandler = (bctbx_file_log_handler_t *)handler->user_info; + bctbx_handler_logv_file_uninit(handler); + bctbx_free(filehandler); + bctbx_handler_uninit(handler); + bctbx_free(handler); } #ifndef _MSC_VER diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/src/tester.c new/bctoolbox-5.3.95/src/tester.c --- old/bctoolbox-5.3.37/src/tester.c 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/src/tester.c 2024-09-18 21:36:16.000000000 +0200 @@ -123,6 +123,11 @@ // Linphone static void (*process_events)(void) = NULL; +typedef struct _suite_status { + int pid; + int finished; +} suite_status_t; + static int bc_tester_registered_suite_count(void) { return CU_get_registry()->uiNumberOfSuites; } @@ -781,12 +786,12 @@ // For parallel tests only - handle anormally exited test suites // Remove previously generated XML suite file if exited anormally (could cause unusable final JUnit XML) // And mark all tests for the suite as failed -static int handle_sub_process_error(int pid, int *suitesPids) { +static int handle_sub_process_error(int pid, suite_status_t *suitesPids) { int failed_tests = 0; int i; int effective_suite_count = bc_tester_registered_suite_count(); for (i = 0; i < effective_suite_count; ++i) { - if (suitesPids[i] == pid) { + if (suitesPids[i].pid == pid) { ssize_t offset; CU_pSuite suite = bc_tester_registered_suite_index(i); char *suite_file_name = get_junit_xml_file_name(suite->pName, "-Results.xml"); @@ -816,12 +821,13 @@ return failed_tests; } -static test_suite_t *lookup_suite_from_pid(int pid, int *suitesPids) { +static test_suite_t *lookup_suite_from_pid(int pid, suite_status_t *suitesStatus, int *index) { int i; int effective_suite_count = bc_tester_registered_suite_count(); for (i = 0; i < effective_suite_count; ++i) { - if (suitesPids[i] == pid) { + if (suitesStatus[i].pid == pid) { CU_pSuite suite = bc_tester_registered_suite_index(i); + if (index) *index = i; if (suite) return (test_suite_t *)suite->pUserData; } } @@ -932,10 +938,12 @@ int bc_tester_run_parallel(void) { int effective_suite_count = bc_tester_registered_suite_count(); - int suitesPids[effective_suite_count]; + suite_status_t suitesPids[effective_suite_count]; uint64_t time_start = bctbx_get_cur_time_ms(), elapsed = time_start, print_timer = time_start; uint64_t timeout = 0; + memset(&suitesPids, 0, sizeof(suite_status_t) * effective_suite_count); + if (globalTimeout <= 0) { globalTimeout = 60 * 60; } @@ -947,8 +955,7 @@ int testsFinished = 0; int ret = 0; // Global return status; int suitesCpuWeight = 0; - - memset(suitesPids, 0, sizeof(suitesPids)); + int timeoutElapsed = 0; do { if (nextSuite < effective_suite_count) { @@ -964,7 +971,7 @@ "Error during fork() while starting child process. Aborting."); return -1; } else if (pid > 0) { - suitesPids[nextSuite] = pid; + suitesPids[nextSuite].pid = pid; runningSuites++; suitesCpuWeight += cpu_weight; nextSuite++; @@ -986,8 +993,10 @@ } if (childPid != 0) { if (WIFEXITED(wstatus) || WIFSIGNALED(wstatus)) { - test_suite_t *finishedSuite = lookup_suite_from_pid(childPid, suitesPids); + int index = 0; + test_suite_t *finishedSuite = lookup_suite_from_pid(childPid, suitesPids, &index); suitesCpuWeight -= test_suite_cpu_weight(finishedSuite); + suitesPids[index].finished = 1; /* reset when suite is finished */ --runningSuites; ++testsFinished; } @@ -1008,12 +1017,25 @@ ret += childRet; } } + bctbx_sleep_ms(50); + if (elapsed - print_timer > 10000) { // print message only every ~10s... + if (!timeoutElapsed && (elapsed >= timeout)) { + int i; + timeoutElapsed = TRUE; + for (i = 0; i < effective_suite_count; ++i) { + if (suitesPids[i].pid != 0 && suitesPids[i].finished == 0) { + CU_pSuite unfinishedSuite = bc_tester_registered_suite_index(i); + bc_tester_printf(bc_printf_verbosity_error, "Suite [%s] is still running after timeout.", + unfinishedSuite->pName); + } + } + } bc_tester_printf(bc_printf_verbosity_error, "Waiting for test suites to finish... Total Suites(%d). Suites running(%d), Finished(%d), " "Timeout reached(%s)", - effective_suite_count, runningSuites, testsFinished, (elapsed >= timeout) ? "yes" : "no"); + effective_suite_count, runningSuites, testsFinished, timeoutElapsed ? "yes" : "no"); print_timer = bctbx_get_cur_time_ms(); } elapsed = bctbx_get_cur_time_ms(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/tester/CMakeLists.txt new/bctoolbox-5.3.95/tester/CMakeLists.txt --- old/bctoolbox-5.3.37/tester/CMakeLists.txt 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/tester/CMakeLists.txt 2024-09-18 21:36:16.000000000 +0200 @@ -43,9 +43,6 @@ string(REPLACE ";" " " LINK_FLAGS_STR "${LINK_FLAGS}") add_executable(bctoolbox-tester-exe ${TESTER_SOURCES}) - if(NOT "${LINK_FLAGS_STR}" STREQUAL "") - set_target_properties(bctoolbox-tester-exe PROPERTIES LINK_FLAGS "${LINK_FLAGS_STR}") - endif() set_target_properties(bctoolbox-tester-exe PROPERTIES OUTPUT_NAME bctoolbox-tester) target_link_libraries(bctoolbox-tester-exe PRIVATE bctoolbox bctoolbox-tester) if(MbedTLS_FOUND) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/bctoolbox-5.3.37/tester/crypto.cc new/bctoolbox-5.3.95/tester/crypto.cc --- old/bctoolbox-5.3.37/tester/crypto.cc 2024-02-08 16:02:05.000000000 +0100 +++ new/bctoolbox-5.3.95/tester/crypto.cc 2024-09-18 21:36:16.000000000 +0200 @@ -569,83 +569,174 @@ std::string expectedString = ""; std::vector<uint8_t> pattern{}; std::vector<uint8_t> resVector{}; + uint8_t b64Buffer[16]; + size_t b64BufferSize = 16; + uint8_t decodedBuffer[16]; + size_t decodedBufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f'}; expectedString = "Zg=="; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f', 'o'}; expectedString = "Zm8="; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f', 'o', 'o'}; expectedString = "Zm9v"; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f', 'o', 'o', 'b'}; expectedString = "Zm9vYg=="; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); + // Same without padding + expectedString = "Zm9vYg"; + resVector.clear(); + resVector = decodeBase64(expectedString); + BC_ASSERT_TRUE(resVector == pattern); + decodedBufferSize = 16; + memset(decodedBuffer, 0, 16); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize - 2) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); + resVector.clear(); + expectedString = "Zm9vYg="; + resVector = decodeBase64(expectedString); + BC_ASSERT_TRUE(resVector == pattern); + decodedBufferSize = 16; + memset(decodedBuffer, 0, 16); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize - 1) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f', 'o', 'o', 'b', 'a'}; expectedString = "Zm9vYmE="; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); resString.clear(); resVector.clear(); + decodedBufferSize = 16; + b64BufferSize = 16; + memset(b64Buffer, 0, 16); + memset(decodedBuffer, 0, 16); pattern = {'f', 'o', 'o', 'b', 'a', 'r'}; expectedString = "Zm9vYmFy"; resString = encodeBase64(pattern); BC_ASSERT_TRUE(resString.compare(expectedString) == 0); + BC_ASSERT_TRUE(bctbx_base64_encode(b64Buffer, &b64BufferSize, pattern.data(), pattern.size()) == 0); + BC_ASSERT_TRUE(b64BufferSize == expectedString.size()); + BC_ASSERT_TRUE(memcmp(b64Buffer, expectedString.data(), b64BufferSize) == 0); resVector = decodeBase64(resString); BC_ASSERT_TRUE(resVector == pattern); + BC_ASSERT_TRUE(bctbx_base64_decode(decodedBuffer, &decodedBufferSize, b64Buffer, b64BufferSize) == 0); + BC_ASSERT_TRUE(decodedBufferSize == pattern.size()); + BC_ASSERT_TRUE(memcmp(decodedBuffer, pattern.data(), decodedBufferSize) == 0); pattern.clear(); expectedString.clear(); ++++++ set_curret_version.patch ++++++ --- /var/tmp/diff_new_pack.ukEiF0/_old 2024-11-12 19:22:00.660951140 +0100 +++ /var/tmp/diff_new_pack.ukEiF0/_new 2024-11-12 19:22:00.664951307 +0100 @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.22) -project(BCToolbox VERSION 5.3.0) -+project(BCToolbox VERSION 5.3.37) ++project(BCToolbox VERSION 5.3.95) set(BCTOOLBOX_VERSION "${PROJECT_VERSION}") set(BCTOOLBOX_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
