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:=
--- /dev/null
+--- 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);
--- /dev/null
+--- 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()
--- /dev/null
+--- 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)
+++ /dev/null
---- 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);