gost_engine: add version 3.0.0.1
authorEneas U de Queiroz <cotequeiroz@gmail.com>
Thu, 9 Feb 2023 13:52:59 +0000 (10:52 -0300)
committerEneas U de Queiroz <cotequeiroz@gmail.com>
Thu, 16 Feb 2023 13:28:52 +0000 (10:28 -0300)
With OpenSSL soon to be updated to 3.0, the gost engine will have to be
bumped as well.  Gost 3.0.0.1 will not build with OpenSSL 1.1.

To avoid disruption, this commit detects the OpenSSL version from
ENGINES_DIR in include/openssl-engin, and sets the package version
accordingly.

Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
libs/gost_engine/Makefile
libs/gost_engine/patches-1.1/010-openssl-deprecated.patch [new file with mode: 0644]
libs/gost_engine/patches-3/020-cmake-allow-cross-compile.patch [new file with mode: 0644]
libs/gost_engine/patches-3/030-dont-build-provider.patch [new file with mode: 0644]
libs/gost_engine/patches/010-openssl-deprecated.patch [deleted file]

index 0ba69f72699daf72ab7b263e8b8c1d5cc38f8cca..94f6c990e5be840a25c85f227c414c295974b43f 100644 (file)
@@ -1,19 +1,27 @@
 include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/openssl-engine.mk
 
 PKG_NAME:=gost_engine
-PKG_VERSION:=1.1.0.3
-PKG_RELEASE:=$(AUTORELEASE)
+ifeq ($(ENGINES_DIR),engines-1.1)
+  PKG_VERSION:=1.1.0.3
+  PKG_HASH:=fff725052e82c9adb5b738729b30141f61ac91fa457a4f4b5de18b8b24092f75
+  PKG_LICENSE:=OpenSSL
+  PATCH_DIR=./patches-1.1
+else
+  PKG_VERSION:=3.0.1
+  PKG_HASH:=bfeac85883724cfbe0ecc6d942ac0524b908143e019ab3d3b6abe47a3466a628
+  PKG_LICENSE:=Apache-2.0
+  PATCH_DIR=./patches-3
+endif
+PKG_RELEASE:=7
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/gost-engine/engine/archive/v$(PKG_VERSION)
-PKG_HASH:=fff725052e82c9adb5b738729b30141f61ac91fa457a4f4b5de18b8b24092f75
 
 PKG_MAINTAINER:=Artur Petrov <github@phpchain.ru>
-PKG_LICENSE:=OpenSSL
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/cmake.mk
-include $(INCLUDE_DIR)/openssl-engine.mk
 
 PKG_UNPACK:=$(HOST_TAR) -C "$(PKG_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
 PKG_INSTALL:=
diff --git a/libs/gost_engine/patches-1.1/010-openssl-deprecated.patch b/libs/gost_engine/patches-1.1/010-openssl-deprecated.patch
new file mode 100644 (file)
index 0000000..c28748a
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/gost_pmeth.c
++++ b/gost_pmeth.c
+@@ -608,7 +608,7 @@ static int pkey_gost_mac_ctrl_str(EVP_PK
+     if (strcmp(type, hexkey_ctrl_string) == 0) {
+         long keylen;
+         int ret;
+-        unsigned char *keybuf = string_to_hex(value, &keylen);
++        unsigned char *keybuf = OPENSSL_hexstr2buf(value, &keylen);
+         if (!keybuf || keylen != 32) {
+             GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
+                     GOST_R_INVALID_MAC_KEY_LENGTH);
diff --git a/libs/gost_engine/patches-3/020-cmake-allow-cross-compile.patch b/libs/gost_engine/patches-3/020-cmake-allow-cross-compile.patch
new file mode 100644 (file)
index 0000000..e1a0e3d
--- /dev/null
@@ -0,0 +1,59 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -64,31 +64,35 @@ else()
+  add_definitions(-DL_ENDIAN)
+ endif()
+-check_c_source_runs("
+-  #ifdef _MSC_VER
+-  # include <intrin.h>
+-  #else
+-  # include <x86intrin.h>
+-  #endif
+-  int main(void) {
+-    unsigned long long x = -1, y = 1, r;
+-    unsigned char cf;
+-    cf = _addcarry_u64(1, x, y, &r);
+-    return !(cf == 1 && r == 1);
+-  }
+-  " ADDCARRY_U64)
++if(NOT CMAKE_CROSSCOMPILING)
++  check_c_source_runs("
++    #ifdef _MSC_VER
++    # include <intrin.h>
++    #else
++    # include <x86intrin.h>
++    #endif
++    int main(void) {
++      unsigned long long x = -1, y = 1, r;
++      unsigned char cf;
++      cf = _addcarry_u64(1, x, y, &r);
++      return !(cf == 1 && r == 1);
++    }
++    " ADDCARRY_U64)
++
++  check_c_source_runs("
++    int main(void) {
++      char buf[16] = { 0, 1, 2 };
++      int *p = (int *)(buf + 1);
++      int *q = (int *)(buf + 2);
++      return (*p == *q);
++    }
++    " RELAXED_ALIGNMENT)
++endif()
++
+ if (ADDCARRY_U64)
+   add_definitions(-DHAVE_ADDCARRY_U64)
+ endif()
+-check_c_source_runs("
+-  int main(void) {
+-    char buf[16] = { 0, 1, 2 };
+-    int *p = (int *)(buf + 1);
+-    int *q = (int *)(buf + 2);
+-    return (*p == *q);
+-  }
+-  " RELAXED_ALIGNMENT)
+ if (NOT RELAXED_ALIGNMENT)
+   add_definitions(-DSTRICT_ALIGNMENT)
+ endif()
diff --git a/libs/gost_engine/patches-3/030-dont-build-provider.patch b/libs/gost_engine/patches-3/030-dont-build-provider.patch
new file mode 100644 (file)
index 0000000..e0e1f5d
--- /dev/null
@@ -0,0 +1,56 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -357,9 +357,11 @@ set_target_properties(lib_gost_engine PR
+   COMPILE_DEFINITIONS "BUILDING_ENGINE_AS_LIBRARY"
+   PUBLIC_HEADER gost-engine.h
+   OUTPUT_NAME "gost")
+-target_link_libraries(lib_gost_engine PRIVATE gost_core gost_err)
++#target_link_libraries(lib_gost_engine PRIVATE gost_core gost_err)
++target_link_libraries(lib_gost_engine PRIVATE gost_core)
+ endif()
++if (0)
+ # The GOST provider uses this
+ add_subdirectory(libprov)
+@@ -384,6 +386,7 @@ set_target_properties(lib_gost_prov PROP
+   )
+ target_link_libraries(lib_gost_prov PRIVATE gost_core libprov)
+ endif()
++endif()
+ set(GOST_SUM_SOURCE_FILES
+         gostsum.c
+@@ -424,15 +427,15 @@ install(FILES gostsum.1 gost12sum.1 DEST
+ install(TARGETS gost_engine EXPORT GostEngineConfig
+         LIBRARY  DESTINATION ${OPENSSL_ENGINES_DIR}
+         RUNTIME  DESTINATION ${OPENSSL_ENGINES_DIR})
+-install(TARGETS gost_prov EXPORT GostProviderConfig
+-        LIBRARY  DESTINATION ${OPENSSL_MODULES_DIR}
+-        RUNTIME  DESTINATION ${OPENSSL_MODULES_DIR})
++#install(TARGETS gost_prov EXPORT GostProviderConfig
++#        LIBRARY  DESTINATION ${OPENSSL_MODULES_DIR}
++#        RUNTIME  DESTINATION ${OPENSSL_MODULES_DIR})
+ if (NOT MSVC)
+ # install engine and provider in library form
+ install(TARGETS lib_gost_engine EXPORT GostEngineConfig
+         LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+-install(TARGETS lib_gost_prov EXPORT GostProviderConfig
+-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
++#install(TARGETS lib_gost_prov EXPORT GostProviderConfig
++#        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ endif()
+ if (MSVC)
+@@ -440,8 +443,8 @@ if (MSVC)
+     EXPORT GostEngineConfig DESTINATION ${CMAKE_INSTALL_BINDIR} OPTIONAL)
+   install(FILES $<TARGET_PDB_FILE:gost_engine>
+     EXPORT GostEngineConfig DESTINATION ${OPENSSL_ENGINES_DIR} OPTIONAL)
+-  install(FILES $<TARGET_PDB_FILE:gost_prov>
+-    EXPORT GostProviderConfig DESTINATION ${OPENSSL_MODULES_DIR} OPTIONAL)
++#  install(FILES $<TARGET_PDB_FILE:gost_prov>
++#    EXPORT GostProviderConfig DESTINATION ${OPENSSL_MODULES_DIR} OPTIONAL)
+ endif()
+ install(EXPORT GostEngineConfig DESTINATION GostEngine/share/cmake/GostEngine)
+-install(EXPORT GostProviderConfig DESTINATION GostEngine/share/cmake/GostProvider)
++#install(EXPORT GostProviderConfig DESTINATION GostEngine/share/cmake/GostProvider)
diff --git a/libs/gost_engine/patches/010-openssl-deprecated.patch b/libs/gost_engine/patches/010-openssl-deprecated.patch
deleted file mode 100644 (file)
index c28748a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/gost_pmeth.c
-+++ b/gost_pmeth.c
-@@ -608,7 +608,7 @@ static int pkey_gost_mac_ctrl_str(EVP_PK
-     if (strcmp(type, hexkey_ctrl_string) == 0) {
-         long keylen;
-         int ret;
--        unsigned char *keybuf = string_to_hex(value, &keylen);
-+        unsigned char *keybuf = OPENSSL_hexstr2buf(value, &keylen);
-         if (!keybuf || keylen != 32) {
-             GOSTerr(GOST_F_PKEY_GOST_MAC_CTRL_STR,
-                     GOST_R_INVALID_MAC_KEY_LENGTH);