Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libcotp for openSUSE:Factory checked 
in at 2024-10-11 17:02:17
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libcotp (Old)
 and      /work/SRC/openSUSE:Factory/.libcotp.new.19354 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libcotp"

Fri Oct 11 17:02:17 2024 rev:14 rq:1206644 version:3.1.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/libcotp/libcotp.changes  2024-04-08 
17:52:19.245793455 +0200
+++ /work/SRC/openSUSE:Factory/.libcotp.new.19354/libcotp.changes       
2024-10-11 17:02:18.358637648 +0200
@@ -1,0 +2,7 @@
+Thu Oct 10 07:59:18 UTC 2024 - Paolo Stivanin <i...@paolostivanin.com>
+
+- Update to 3.1.0:
+  * add support for mbedtls (#69, thanks to @Rockyshen123)
+  * add support for big endian archs (#68)-
+
+-------------------------------------------------------------------

Old:
----
  v3.0.0.tar.gz
  v3.0.0.tar.gz.asc

New:
----
  v3.1.0.tar.gz
  v3.1.0.tar.gz.asc

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libcotp.spec ++++++
--- /var/tmp/diff_new_pack.5rXu39/_old  2024-10-11 17:02:18.954662439 +0200
+++ /var/tmp/diff_new_pack.5rXu39/_new  2024-10-11 17:02:18.962662772 +0200
@@ -16,11 +16,15 @@
 #
 
 
+%if 0%{?suse_version} > 1600
+%ifarch x86_64
 %bcond_with criterion
+%endif
+%endif
 
 %define libsoname %{name}3
 Name:           libcotp
-Version:        3.0.0
+Version:        3.1.0
 Release:        0
 Summary:        C library for generating TOTP and HOTP
 License:        Apache-2.0
@@ -32,10 +36,8 @@
 BuildRequires:  cmake
 BuildRequires:  gcc
 %if %{with criterion}
-%ifarch x86_64
 BuildRequires:  libcriterion-devel
 %endif
-%endif
 BuildRequires:  libgcrypt-devel >= 1.8.0
 BuildRequires:  pkgconfig
 Obsoletes:      libbaseencode <= 1.0.15
@@ -68,10 +70,8 @@
 %build
 %cmake \
 %if %{with criterion}
-%ifarch x86_64
   -DBUILD_TESTS=ON \
 %endif
-%endif
   -DBUILD_SHARED_LIBS=ON \
   -DHMAC_WRAPPER="gcrypt"
 %cmake_build
@@ -80,14 +80,12 @@
 %cmake_install
 
 %if %{with criterion}
-%ifarch x86_64
 %check
 cd build
 ./tests/test_base32encode
 ./tests/test_base32decode
 ./tests/test_cotp
 %endif
-%endif
 
 %post -n        %{libsoname} -p /sbin/ldconfig
 %postun -n      %{libsoname} -p /sbin/ldconfig


++++++ v3.0.0.tar.gz -> v3.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/.circleci/config.yml 
new/libcotp-3.1.0/.circleci/config.yml
--- old/libcotp-3.0.0/.circleci/config.yml      2023-12-13 09:42:15.000000000 
+0100
+++ new/libcotp-3.1.0/.circleci/config.yml      2024-10-04 13:42:33.000000000 
+0200
@@ -1,13 +1,14 @@
 version: 2.0
 
 jobs:
-  debian:
+  debianStable_gcrypt:
     docker:
-      - image: debian:testing
+      - image: debian:stable
     steps:
       - checkout
       - run:
           command: |
+            export DEBIAN_FRONTEND=noninteractive
             apt update && apt -y install git gcc clang cmake libcriterion-dev 
libgcrypt20-dev
             mkdir build && cd "$_"
             cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON ..
@@ -15,14 +16,14 @@
             ./tests/test_base32encode
             ./tests/test_base32decode
             ./tests/test_cotp
-
-  ubuntu:
+  ubuntu2404_gcrypt:
     docker:
-      - image: ubuntu:latest
+      - image: ubuntu:24.04
     steps:
       - checkout
       - run:
           command: |
+            export DEBIAN_FRONTEND=noninteractive
             apt update && apt -y install git gcc clang cmake libcriterion-dev 
libgcrypt20-dev
             mkdir build && cd "$_"
             cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON ..
@@ -30,10 +31,73 @@
             ./tests/test_base32encode
             ./tests/test_base32decode
             ./tests/test_cotp
-
+  debianStable_openssl:
+    docker:
+      - image: debian:stable
+    steps:
+      - checkout
+      - run:
+          command: |
+            export DEBIAN_FRONTEND=noninteractive
+            apt update && apt -y install git gcc clang cmake libcriterion-dev 
libssl-dev
+            mkdir build && cd "$_"
+            cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON 
-DHMAC_WRAPPER=openssl ..
+            make && make install
+            ./tests/test_base32encode
+            ./tests/test_base32decode
+            ./tests/test_cotp
+  ubuntu2404_openssl:
+    docker:
+      - image: ubuntu:24.04
+    steps:
+      - checkout
+      - run:
+          command: |
+            export DEBIAN_FRONTEND=noninteractive
+            apt update && apt -y install git gcc clang cmake libcriterion-dev 
libssl-dev
+            mkdir build && cd "$_"
+            cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON 
-DHMAC_WRAPPER=openssl ..
+            make && make install
+            ./tests/test_base32encode
+            ./tests/test_base32decode
+            ./tests/test_cotp
+  debianStable_mbedtls:
+    docker:
+      - image: debian:stable
+    steps:
+      - checkout
+      - run:
+          command: |
+            export DEBIAN_FRONTEND=noninteractive
+            apt update && apt -y install git gcc clang cmake libcriterion-dev 
libmbedtls-dev
+            mkdir build && cd "$_"
+            cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON 
-DHMAC_WRAPPER=mbedtls ..
+            make && make install
+            ./tests/test_base32encode
+            ./tests/test_base32decode
+            ./tests/test_cotp
+  ubuntu2404_mbedtls:
+    docker:
+      - image: ubuntu:24.04
+    steps:
+      - checkout
+      - run:
+          command: |
+            export DEBIAN_FRONTEND=noninteractive
+            apt update && apt -y install git gcc clang cmake libcriterion-dev 
libmbedtls-dev
+            mkdir build && cd "$_"
+            cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTS=ON 
-DHMAC_WRAPPER=mbedtls ..
+            make && make install
+            ./tests/test_base32encode
+            ./tests/test_base32decode
+            ./tests/test_cotp
 workflows:
   version: 2
   build:
     jobs:
-      - debian
-      - ubuntu
+      - debianStable_gcrypt
+      - ubuntu2404_gcrypt
+      - debianStable_openssl
+      - ubuntu2404_openssl
+      - debianStable_mbedtls
+      - ubuntu2404_mbedtls
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/CMakeLists.txt 
new/libcotp-3.1.0/CMakeLists.txt
--- old/libcotp-3.0.0/CMakeLists.txt    2023-12-13 09:42:15.000000000 +0100
+++ new/libcotp-3.1.0/CMakeLists.txt    2024-10-04 13:42:33.000000000 +0200
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.16)
-project(cotp VERSION "3.0.0" LANGUAGES "C")
+project(cotp VERSION "3.1.0" LANGUAGES "C")
 
 set(CMAKE_C_STANDARD 11)
 
@@ -7,19 +7,19 @@
 
 include(GNUInstallDirs)
 
-find_package(PkgConfig REQUIRED)
+find_package(PkgConfig)
 
 option(BUILD_SHARED_LIBS "Build libcotp as a shared library" ON)
 option(BUILD_TESTS "Build base32 and cotp tests" OFF)
+set(HMAC_WRAPPER "gcrypt" CACHE STRING "Choose between gcrypt (default), 
openssl or mbedtls for HMAC computation")
+set_property(CACHE HMAC_WRAPPER PROPERTY STRINGS "gcrypt" "openssl" "mbedtls")
 
-set(HMAC_WRAPPER "gcrypt" CACHE STRING "library to use during hmac 
computation")
 if("${HMAC_WRAPPER}" STREQUAL "gcrypt")
     set(HMAC_SOURCE_FILES
             src/utils/whmac_gcrypt.c
     )
     find_package(Gcrypt 1.8.0 REQUIRED)
     set(HMAC_INCLUDE_DIR ${GCRYPT_INCLUDE_DIR})
-    set(HMAC_LIBRARY_DIRS ${GCRYPT_LIBRARY_DIRS})
     set(HMAC_LIBRARIES ${GCRYPT_LIBRARIES})
     message("libcotp will use gcrypt for hmac")
 elseif("${HMAC_WRAPPER}" STREQUAL "openssl")
@@ -28,15 +28,21 @@
             src/utils/whmac_openssl.c
     )
     set(HMAC_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR})
-    set(HMAC_LIBRARY_DIRS ${OPENSSL_LIBRARY_DIRS})
     set(HMAC_LIBRARIES ${OPENSSL_LIBRARIES})
     message("libcotp will use openssl for hmac")
+elseif("${HMAC_WRAPPER}" STREQUAL "mbedtls")
+    find_package(MbedTLS REQUIRED)
+    set(HMAC_SOURCE_FILES
+            src/utils/whmac_mbedtls.c
+    )
+    set(HMAC_INCLUDE_DIR ${MBEDTLS_INCLUDE_DIRS})
+    set(HMAC_LIBRARIES ${MBEDTLS_LIBRARIES})
+    message("libcotp will use mbedtls for hmac")
 else()
     message("libcotp can't use ${HMAC_WRAPPER} for hmac")
 endif()
 
 include_directories(${HMAC_INCLUDE_DIR})
-link_directories(${HMAC_LIBRARY_DIRS})
 
 if (BUILD_TESTS)
     add_subdirectory(tests)
@@ -53,9 +59,11 @@
 )
 
 # Set compiler flags for all targets
-add_compile_options(-Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute 
-fstack-protector-strong -Wundef -Wmissing-format-attribute
-        -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code 
-Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast
-        -Wcast-align -Werror=format-security 
-Werror=implicit-function-declaration -Wno-sign-compare -Wno-format-nonliteral 
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3)
+if(NOT MSVC)
+    add_compile_options(-Wall -Wextra -O3 -Wformat=2 
-Wmissing-format-attribute -fstack-protector-strong -Wundef 
-Wmissing-format-attribute
+            -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code 
-Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast
+            -Wcast-align -Werror=format-security 
-Werror=implicit-function-declaration -Wno-sign-compare -Wno-format-nonliteral 
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3)
+endif()
 
 add_library(cotp ${SOURCE_FILES})
 
@@ -65,10 +73,12 @@
             ${CMAKE_CURRENT_SOURCE_DIR}/src
         PRIVATE
             ${HMAC_INCLUDE_DIR})
-target_compile_options(cotp PRIVATE
-        -Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute 
-fstack-protector-strong -Wundef -Wmissing-format-attribute
-        -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code 
-Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast
-        -Wcast-align -Werror=format-security 
-Werror=implicit-function-declaration -Wno-sign-compare -Wno-format-nonliteral 
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3)
+if(NOT MSVC)
+    target_compile_options(cotp PRIVATE
+            -Wall -Wextra -O3 -Wformat=2 -Wmissing-format-attribute 
-fstack-protector-strong -Wundef -Wmissing-format-attribute
+            -fdiagnostics-color=always -Wstrict-prototypes -Wunreachable-code 
-Wchar-subscripts -Wwrite-strings -Wpointer-arith -Wbad-function-cast
+            -Wcast-align -Werror=format-security 
-Werror=implicit-function-declaration -Wno-sign-compare -Wno-format-nonliteral 
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3)
+endif()
 target_link_directories(cotp PRIVATE
         ${HMACLIBRARY_DIRS})
 
@@ -89,19 +99,20 @@
   DESTINATION ${COTP_INC_DIR}
 )
 
-# Allow adding prefix if CMAKE_INSTALL_INCLUDEDIR not absolute.
-if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
-    set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}")
-else()
-    set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
-endif()
-# Allow adding prefix if CMAKE_INSTALL_LIBDIR not absolute.
-if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
-    set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_LIBDIR}")
-else()
-    set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
-endif()
-
-configure_file("cotp.pc.in" "cotp.pc" @ONLY)
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cotp.pc" DESTINATION 
${CMAKE_INSTALL_LIBDIR}/pkgconfig/)
+if (PkgConfig_FOUND)
+    # Allow adding prefix if CMAKE_INSTALL_INCLUDEDIR not absolute.
+    if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
+        set(PKGCONFIG_TARGET_INCLUDES "${CMAKE_INSTALL_INCLUDEDIR}")
+    else()
+        set(PKGCONFIG_TARGET_INCLUDES "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
+    endif()
+    # Allow adding prefix if CMAKE_INSTALL_LIBDIR not absolute.
+    if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+        set(PKGCONFIG_TARGET_LIBS "${CMAKE_INSTALL_LIBDIR}")
+    else()
+        set(PKGCONFIG_TARGET_LIBS "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
+    endif()
 
+    configure_file("cotp.pc.in" "cotp.pc" @ONLY)
+    install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cotp.pc" DESTINATION 
${CMAKE_INSTALL_LIBDIR}/pkgconfig/)
+endif()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/README.md new/libcotp-3.1.0/README.md
--- old/libcotp-3.0.0/README.md 2023-12-13 09:42:15.000000000 +0100
+++ new/libcotp-3.1.0/README.md 2024-10-04 13:42:33.000000000 +0200
@@ -8,7 +8,7 @@
 
 ## Requirements
 - GCC/Clang and CMake to build the library
-- libgcrypt or openssl
+- libgcrypt >= 1.8.0 or openssl >= 3.0.0 or mbedtls (works with both 2.x and 
3.x)
 
 ## Build and Install
 ```
@@ -17,13 +17,13 @@
 $ mkdir build && cd $_
 $ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
 $ make
-# make install
+$ sudo make install
 ```
 
 Available options you can pass to `cmake`:
 * `-DBUILD_TESTS=ON`: if you want to compile also the tests (default **OFF**, 
requires criterion)
-* `-DBUILD_SHARED_LIBS=ON`: if you want to build libcotp as a shared library 
(default **ON**)
-* `-DHMAC_WRAPPER="<gcrypt|openssl>"`: you can choose between GCrypt and 
OpenSSL (default **Gcrypt**)
+* `-DBUILD_SHARED_LIBS=OFF`: if you want to build libcotp as a static library 
(default **ON**)
+* `-DHMAC_WRAPPER="<gcrypt|openssl|mbedtls>"`: you can choose between GCrypt, 
OpenSSL or MbedTLS (default **Gcrypt**)
 
 ## How To Use It
 ```
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/cmake/FindGcrypt.cmake 
new/libcotp-3.1.0/cmake/FindGcrypt.cmake
--- old/libcotp-3.0.0/cmake/FindGcrypt.cmake    2023-12-13 09:42:15.000000000 
+0100
+++ new/libcotp-3.1.0/cmake/FindGcrypt.cmake    2024-10-04 13:42:33.000000000 
+0200
@@ -15,7 +15,10 @@
 
 find_path(GCRYPT_INCLUDE_DIR gcrypt.h)
 
-find_library(GCRYPT_LIBRARIES gcrypt)
+if(WIN32)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll" ".dll.a")
+endif()
+find_library(GCRYPT_LIBRARIES NAMES gcrypt libgcrypt)
 
 mark_as_advanced(GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIR)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/cmake/FindMbedTLS.cmake 
new/libcotp-3.1.0/cmake/FindMbedTLS.cmake
--- old/libcotp-3.0.0/cmake/FindMbedTLS.cmake   1970-01-01 01:00:00.000000000 
+0100
+++ new/libcotp-3.1.0/cmake/FindMbedTLS.cmake   2024-10-04 13:42:33.000000000 
+0200
@@ -0,0 +1,111 @@
+#***************************************************************************
+#                                  _   _ ____  _
+#  Project                     ___| | | |  _ \| |
+#                             / __| | | | |_) | |
+#                            | (__| |_| |  _ <| |___
+#                             \___|\___/|_| \_\_____|
+#
+# Copyright (C) Daniel Stenberg, <dan...@haxx.se>, et al.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution. The terms
+# are also available at https://curl.se/docs/copyright.html.
+#
+# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+# copies of the Software, and permit persons to whom the Software is
+# furnished to do so, under the terms of the COPYING file.
+#
+# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+# KIND, either express or implied.
+#
+# SPDX-License-Identifier: curl
+#
+###########################################################################
+# Find the mbedtls library
+#
+# Input variables:
+#
+# MBEDTLS_INCLUDE_DIR   The mbedtls include directory
+# MBEDTLS_INCLUDE_DIRS  The mbedtls include directory (deprecated)
+# MBEDTLS_LIBRARY       Path to mbedtls library
+# MBEDX509_LIBRARY      Path to mbedx509 library
+# MBEDCRYPTO_LIBRARY    Path to mbedcrypto library
+#
+# Result variables:
+#
+# MBEDTLS_FOUND         System has mbedtls
+# MBEDTLS_INCLUDE_DIRS  The mbedtls include directories
+# MBEDTLS_LIBRARIES     The mbedtls library names
+# MBEDTLS_VERSION       Version of mbedtls
+
+if(DEFINED MBEDTLS_INCLUDE_DIRS AND NOT DEFINED MBEDTLS_INCLUDE_DIR)
+    message(WARNING "MBEDTLS_INCLUDE_DIRS is deprecated, use 
MBEDTLS_INCLUDE_DIR instead.")
+    set(MBEDTLS_INCLUDE_DIR "${MBEDTLS_INCLUDE_DIRS}")
+    unset(MBEDTLS_INCLUDE_DIRS)
+endif()
+
+if(CURL_USE_PKGCONFIG)
+    find_package(PkgConfig QUIET)
+    pkg_check_modules(PC_MBEDTLS "mbedtls")
+endif()
+
+find_path(MBEDTLS_INCLUDE_DIR NAMES "mbedtls/ssl.h"
+        HINTS
+        ${PC_MBEDTLS_INCLUDEDIR}
+        ${PC_MBEDTLS_INCLUDE_DIRS}
+)
+
+find_library(MBEDTLS_LIBRARY NAMES "mbedtls"
+        HINTS
+        ${PC_MBEDTLS_LIBDIR}
+        ${PC_MBEDTLS_LIBRARY_DIRS}
+)
+find_library(MBEDX509_LIBRARY NAMES "mbedx509"
+        HINTS
+        ${PC_MBEDTLS_LIBDIR}
+        ${PC_MBEDTLS_LIBRARY_DIRS}
+)
+find_library(MBEDCRYPTO_LIBRARY NAMES "mbedcrypto"
+        HINTS
+        ${PC_MBEDTLS_LIBDIR}
+        ${PC_MBEDTLS_LIBRARY_DIRS}
+)
+
+if(PC_MBEDTLS_VERSION)
+    set(MBEDTLS_VERSION ${PC_MBEDTLS_VERSION})
+elseif(MBEDTLS_INCLUDE_DIR)
+    if(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h")  # 3.x
+        set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/build_info.h")
+    elseif(EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")  # 2.x
+        set(_version_header "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
+    else()
+        unset(_version_header)
+    endif()
+    if(_version_header)
+        set(_version_regex "#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t 
]+\"([0-9.]+)\"")
+        file(STRINGS "${_version_header}" _version_str REGEX 
"${_version_regex}")
+        string(REGEX REPLACE "${_version_regex}" "\\1" _version_str 
"${_version_str}")
+        set(MBEDTLS_VERSION "${_version_str}")
+        unset(_version_regex)
+        unset(_version_str)
+        unset(_version_header)
+    endif()
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(MbedTLS
+        REQUIRED_VARS
+        MBEDTLS_INCLUDE_DIR
+        MBEDTLS_LIBRARY
+        MBEDX509_LIBRARY
+        MBEDCRYPTO_LIBRARY
+        VERSION_VAR
+        MBEDTLS_VERSION
+)
+
+if(MBEDTLS_FOUND)
+    set(MBEDTLS_INCLUDE_DIRS ${MBEDTLS_INCLUDE_DIR})
+    set(MBEDTLS_LIBRARIES    ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} 
${MBEDCRYPTO_LIBRARY})
+endif()
+
+mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARY MBEDX509_LIBRARY 
MBEDCRYPTO_LIBRARY)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/src/otp.c new/libcotp-3.1.0/src/otp.c
--- old/libcotp-3.0.0/src/otp.c 2023-12-13 09:42:15.000000000 +0100
+++ new/libcotp-3.1.0/src/otp.c 2024-10-04 13:42:33.000000000 +0200
@@ -6,6 +6,20 @@
 #include "whmac.h"
 #include "cotp.h"
 
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define REVERSE_BYTES(C, C_reverse_byte_order)           \
+        for (int j = 0, i = 7; j < 8; j++, i--) {            \
+            (C_reverse_byte_order)[i] = ((unsigned char *)&(C))[j]; \
+        }
+#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#define REVERSE_BYTES(C, C_reverse_byte_order)           \
+        for (int j = 0; j < 8; j++) {                        \
+            (C_reverse_byte_order)[j] = ((unsigned char *)&(C))[j]; \
+        }
+#else
+    #error "Unknown endianness"
+#endif
+
 static char  *normalize_secret (const char  *K);
 
 static char  *get_steam_code   (const uchar *hmac,
@@ -278,13 +292,10 @@
     }
 
     unsigned char C_reverse_byte_order[8];
-    int j, i;
-    for (j = 0, i = 7; j < 8 && i >= 0; j++, i--) {
-        C_reverse_byte_order[i] = ((unsigned char *) &C)[j];
-    }
+    REVERSE_BYTES(C, C_reverse_byte_order);
 
-    cotp_error_t copterr = whmac_setkey (hd, secret, secret_len);
-    if (copterr) {
+    err = whmac_setkey (hd, secret, secret_len);
+    if (err) {
         fprintf (stderr, "Error while setting the cipher key.\n");
         free (secret);
         return NULL;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/src/utils/whmac_mbedtls.c 
new/libcotp-3.1.0/src/utils/whmac_mbedtls.c
--- old/libcotp-3.0.0/src/utils/whmac_mbedtls.c 1970-01-01 01:00:00.000000000 
+0100
+++ new/libcotp-3.1.0/src/utils/whmac_mbedtls.c 2024-10-04 13:42:33.000000000 
+0200
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <mbedtls/md.h>
+#include "../whmac.h"
+#include "../cotp.h"
+
+typedef struct whmac_handle_s whmac_handle_t;
+
+struct whmac_handle_s
+{
+    mbedtls_md_context_t sha_ctx;
+    const mbedtls_md_info_t *md_info;
+    int algo;
+    size_t dlen;
+};
+
+int
+whmac_check (void)
+{
+    return 0;
+}
+
+size_t
+whmac_getlen (whmac_handle_t *hd)
+{
+    return mbedtls_md_get_size(hd->md_info);
+}
+
+whmac_handle_t *
+whmac_gethandle (int algo)
+{
+    const mbedtls_md_type_t openssl_algo[] = {
+        MBEDTLS_MD_SHA1,
+        MBEDTLS_MD_SHA256,
+        MBEDTLS_MD_SHA512,
+    };
+
+    whmac_handle_t *whmac_handle = calloc (1, sizeof(*whmac_handle));
+    if (whmac_handle == NULL) {
+        return NULL;
+    }
+
+    if (algo > 2) {
+        free (whmac_handle);
+        return NULL;
+    }
+    
+    mbedtls_md_init (&(whmac_handle->sha_ctx));
+    whmac_handle->md_info = mbedtls_md_info_from_type (openssl_algo[algo]);
+    int ret = mbedtls_md_setup (&(whmac_handle->sha_ctx), 
whmac_handle->md_info, 1);
+    if (ret != 0) {
+        printf ("mbedtls_md_setup() returned -0x%04x\n", -ret);
+        mbedtls_md_free (&(whmac_handle->sha_ctx));
+        free (whmac_handle);
+        return NULL;
+    }
+
+    return whmac_handle;
+}
+
+void
+whmac_freehandle (whmac_handle_t *hd)
+{
+    mbedtls_md_free (&(hd->sha_ctx));
+    free (hd);
+}
+
+int
+whmac_setkey (whmac_handle_t *hd,
+              unsigned char *buffer,
+              size_t buflen)
+{
+    mbedtls_md_hmac_starts (&(hd->sha_ctx), buffer, buflen);
+    return NO_ERROR;
+}
+
+void
+whmac_update (whmac_handle_t *hd,
+              unsigned char *buffer,
+              size_t buflen)
+{   
+    mbedtls_md_hmac_update (&(hd->sha_ctx), buffer, buflen);
+}
+
+ssize_t
+whmac_finalize (whmac_handle_t *hd,
+                unsigned char *buffer,
+                size_t buflen)
+{
+    mbedtls_md_hmac_finish (&(hd->sha_ctx), buffer);
+
+    return buflen;
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/src/utils/whmac_openssl.c 
new/libcotp-3.1.0/src/utils/whmac_openssl.c
--- old/libcotp-3.0.0/src/utils/whmac_openssl.c 2023-12-13 09:42:15.000000000 
+0100
+++ new/libcotp-3.1.0/src/utils/whmac_openssl.c 2024-10-04 13:42:33.000000000 
+0200
@@ -52,8 +52,8 @@
 
         size_t params_n = 0;
 
-        whmac_handle->mac_params[params_n++] = 
OSSL_PARAM_construct_utf8_string("digest", (char *)openssl_algo[algo], 0);
-        whmac_handle->mac_params[params_n] = OSSL_PARAM_construct_end();
+        whmac_handle->mac_params[params_n++] = 
OSSL_PARAM_construct_utf8_string ("digest", (char *)openssl_algo[algo], 0);
+        whmac_handle->mac_params[params_n] = OSSL_PARAM_construct_end ();
     }
     return whmac_handle;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/src/whmac.h 
new/libcotp-3.1.0/src/whmac.h
--- old/libcotp-3.0.0/src/whmac.h       2023-12-13 09:42:15.000000000 +0100
+++ new/libcotp-3.1.0/src/whmac.h       2024-10-04 13:42:33.000000000 +0200
@@ -1,5 +1,9 @@
 #pragma once
 
+#if defined(_MSC_VER)
+typedef long ssize_t;
+#endif
+
 typedef struct whmac_handle_s whmac_handle_t;
 
 int             whmac_check      (void);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libcotp-3.0.0/tests/CMakeLists.txt 
new/libcotp-3.1.0/tests/CMakeLists.txt
--- old/libcotp-3.0.0/tests/CMakeLists.txt      2023-12-13 09:42:15.000000000 
+0100
+++ new/libcotp-3.1.0/tests/CMakeLists.txt      2024-10-04 13:42:33.000000000 
+0200
@@ -2,9 +2,14 @@
 add_executable (test_base32encode test_base32encode.c)
 add_executable (test_base32decode test_base32decode.c)
 
-target_link_libraries (test_cotp -lcotp -lcriterion -lgcrypt)
-target_link_libraries (test_base32encode -lcotp -lcriterion -lgcrypt)
-target_link_libraries (test_base32decode -lcotp -lcriterion -lgcrypt)
+if("${HMAC_WRAPPER}" STREQUAL "gcrypt")
+    set(HMAC_LIBRARIES ${GCRYPT_LIBRARIES})
+elseif("${HMAC_WRAPPER}" STREQUAL "openssl")
+    set(HMAC_LIBRARIES ${OPENSSL_LIBRARIES})
+endif()
+target_link_libraries (test_cotp -lcotp -lcriterion ${HMAC_LIBRARIES})
+target_link_libraries (test_base32encode -lcotp -lcriterion ${HMAC_LIBRARIES})
+target_link_libraries (test_base32decode -lcotp -lcriterion ${HMAC_LIBRARIES})
 target_link_directories (test_cotp PRIVATE ${PROJECT_BINARY_DIR})
 target_link_directories (test_base32encode PRIVATE ${PROJECT_BINARY_DIR})
 target_link_directories (test_base32decode PRIVATE ${PROJECT_BINARY_DIR})

Reply via email to