diff --git a/0002-feat-for-embedded-fix-huks-compile-errors.patch b/0002-feat-for-embedded-fix-huks-compile-errors.patch new file mode 100644 index 0000000..98ffd7e --- /dev/null +++ b/0002-feat-for-embedded-fix-huks-compile-errors.patch @@ -0,0 +1,111 @@ +From b8a21d565f44303187ade8245e637c261906451f Mon Sep 17 00:00:00 2001 +From: s_c_c +Date: Tue, 2 Apr 2024 16:59:34 +0800 +Subject: [PATCH] feat for embedded fix huks compile errors + +--- + frameworks/huks_standard/main/core/src/hks_verifier.c | 1 + + .../main/crypto_engine/openssl/src/hks_openssl_sm2.c | 4 ++-- + .../huks_service/main/os_dependency/idl/BUILD.gn | 1 + + utils/crypto_adapter/hks_client_service_adapter.c | 8 ++++---- + utils/file_operator/BUILD.gn | 1 + + 5 files changed, 9 insertions(+), 6 deletions(-) + +diff --git a/frameworks/huks_standard/main/core/src/hks_verifier.c b/frameworks/huks_standard/main/core/src/hks_verifier.c +index c9bf5ae..5e3d1a4 100644 +--- a/frameworks/huks_standard/main/core/src/hks_verifier.c ++++ b/frameworks/huks_standard/main/core/src/hks_verifier.c +@@ -253,6 +253,7 @@ static int32_t EncodeTlvAndGetLength(uint8_t **buf, uint32_t *outLength, uint32_ + + uint32_t tmp; + HKS_ASN1_DECODE_BYTE(*buf, tmp); /* get type */ ++ (void)tmp; + if ((*buf)[0] < ASN_1_MIN_VAL_1_EXTRA_LEN_BYTE) { + /* Current byte tells the length */ + HKS_ASN1_DECODE_BYTE(*buf, length); +diff --git a/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c b/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c +index 0dbe0d5..3451d17 100644 +--- a/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c ++++ b/frameworks/huks_standard/main/crypto_engine/openssl/src/hks_openssl_sm2.c +@@ -163,12 +163,12 @@ static EVP_PKEY_CTX *InitSm2Ctx(const struct HksBlob *mainKey, uint32_t digest, + HKS_LOG_E("assign ec key failed"); + break; + } +- ++#if OPENSSL_VERSION_MAJOR < 3 + if (EVP_PKEY_set_alias_type(key, EVP_PKEY_SM2) != HKS_OPENSSL_SUCCESS) { + HKS_LOG_E("set alias type failed"); + break; + } +- ++#endif + ctx = EVP_PKEY_CTX_new(key, NULL); + HKS_IF_NULL_LOGE_BREAK(ctx, "new ctx failed") + +diff --git a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +index c1f2e20..c7f2283 100644 +--- a/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn ++++ b/services/huks_standard/huks_service/main/os_dependency/idl/BUILD.gn +@@ -60,6 +60,7 @@ ohos_static_library("libhuks_service_idl_standard_static") { + "-DHILOG_ENABLE", + "-Wall", + "-Werror", ++ "-Wno-attributes", + ] + cflags = cflags_cc + complete_static_lib = true +diff --git a/utils/crypto_adapter/hks_client_service_adapter.c b/utils/crypto_adapter/hks_client_service_adapter.c +index ae9f94d..ee2c303 100644 +--- a/utils/crypto_adapter/hks_client_service_adapter.c ++++ b/utils/crypto_adapter/hks_client_service_adapter.c +@@ -428,7 +428,7 @@ int32_t TranslateToX509PublicKey(const struct HksBlob *publicKey, struct HksBlob + #ifdef HKS_SUPPORT_RSA_C + static int32_t X509PublicKeyToRsa(EVP_PKEY *pkey, struct HksBlob *rsaPublicKey) + { +- RSA *rsa = EVP_PKEY_get0_RSA(pkey); ++ RSA *rsa = (RSA *)EVP_PKEY_get0_RSA(pkey); + HKS_IF_NULL_LOGE_RETURN(rsa, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_RSA error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -521,7 +521,7 @@ static int32_t EcKeyToPublicKey(const uint32_t alg, EC_KEY *ecKey, struct HksBlo + + static int32_t X509PublicKeyToEcc(const uint32_t alg, EVP_PKEY *pkey, struct HksBlob *eccPublicKey) + { +- EC_KEY *ecKey = EVP_PKEY_get0_EC_KEY(pkey); ++ EC_KEY *ecKey = (EC_KEY *)EVP_PKEY_get0_EC_KEY(pkey); + HKS_IF_NULL_LOGE_RETURN(ecKey, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_EC_KEY error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -547,7 +547,7 @@ static int32_t GetDsaKeyInfo(const DSA *dsa, const BIGNUM **info, uint32_t *info + + static int32_t X509PublicKeyToDsa(EVP_PKEY *pkey, struct HksBlob *dsaPublicKey) + { +- DSA *dsa = EVP_PKEY_get0_DSA(pkey); ++ DSA *dsa = (DSA *)EVP_PKEY_get0_DSA(pkey); + HKS_IF_NULL_LOGE_RETURN(dsa, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get1_DSA error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +@@ -604,7 +604,7 @@ static int32_t X509PublicKeyToDsa(EVP_PKEY *pkey, struct HksBlob *dsaPublicKey) + #ifdef HKS_SUPPORT_DH_C + static int32_t X509PublicKeyToDh(EVP_PKEY *pkey, struct HksBlob *dhPublicKey) + { +- DH *dh = EVP_PKEY_get0_DH(pkey); ++ DH *dh = (DH *)EVP_PKEY_get0_DH(pkey); + HKS_IF_NULL_LOGE_RETURN(dh, HKS_ERROR_NULL_POINTER, + "EVP_PKEY_get0_DH error %" LOG_PUBLIC "s", ERR_reason_error_string(ERR_get_error())) + +diff --git a/utils/file_operator/BUILD.gn b/utils/file_operator/BUILD.gn +index 8666d7f..841e3e1 100644 +--- a/utils/file_operator/BUILD.gn ++++ b/utils/file_operator/BUILD.gn +@@ -41,6 +41,7 @@ ohos_static_library("libhuks_utils_file_operator_static") { + cflags = [ + "-Wall", + "-Werror", ++ "-Wno-unused-result", + ] + deps = [ "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static" ] + external_deps = [ +-- +2.20.1 (Apple Git-117) + diff --git a/security_huks.spec b/security_huks.spec index 88ad5bb..89ea767 100644 --- a/security_huks.spec +++ b/security_huks.spec @@ -6,7 +6,7 @@ Name: security_huks Version: 1.0.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Key management service License: Apache-2.0 URL: https://gitee.com/openharmony/security_huks @@ -16,6 +16,7 @@ Source3: huks.bundle.json Source4: huks_service.xml Patch1: 0001-adapt-compilation-tailor-dependencies.patch +Patch2: 0002-feat-for-embedded-fix-huks-compile-errors.patch BuildRequires: gcc, make, hilog BuildRequires: distributed-build, distributed-beget @@ -48,6 +49,7 @@ cp -rf %{_builddir}/build/openeuler/compiler_gn/* %{_builddir} %setup -q -D -T -a 1 -c -n %{security_path} mv %{security_path}/%{name}-%{oh_version} %{security_path}/huks %patch -P1 -p1 -d %{security_path}/huks +%patch -P2 -p1 -d %{security_path}/huks %build @@ -108,6 +110,9 @@ ln -s /usr/include/huks %{buildroot}%{build_opt}/openeuler/compiler_gn/base/sec %{build_opt}/* %changelog +* Tue Apr 2 2024 s_c_c - 1.0.0-4 +- Fix huks compile errors for embedded + * Fri Dec 15 2023 Peng He - 1.0.0-3 - add sa profile file