From 4802e97ac7e1c84694a79c7f8724d99e7646d477 Mon Sep 17 00:00:00 2001 From: CheungVane Date: Tue, 8 Nov 2022 19:06:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BA=A7=E5=93=81=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2MbedTls=E5=92=8COpenSSL=20Signed-off-by:=20zhangwenzhi?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/config.gni | 6 +++++ .../main/crypto_engine/mbedtls/BUILD.gn | 23 +++++++++++-------- .../main/crypto_engine/openssl/BUILD.gn | 13 ++++++----- interfaces/innerkits/huks_lite/BUILD.gn | 23 +++++++++++++------ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/build/config.gni b/build/config.gni index e65619fc..397648dc 100755 --- a/build/config.gni +++ b/build/config.gni @@ -36,4 +36,10 @@ declare_args() { # whether huks enable log huks_enable_log = false + + # specify the MbedTls huks depends on + huks_dependency_mbedtls_path = "" + + # specify the OpenSSL huks depends on + huks_dependency_openssl_path = "" } diff --git a/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn b/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn index 2fde7770..ddd52675 100644 --- a/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn +++ b/frameworks/huks_standard/main/crypto_engine/mbedtls/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/security/huks/build/config.gni") import("//build/ohos.gni") config("huks_config") { @@ -27,11 +28,7 @@ ohos_static_library("libhuks_mbedtls_standard_static") { part_name = "huks" public_configs = [ ":huks_config" ] - include_dirs = [ - "//commonlibrary/c_utils/base/include", - "//third_party/openssl/include/", - "//third_party/openssl/crypto/ec/", - ] + include_dirs = [ "//commonlibrary/c_utils/base/include" ] defines = [ "L2_STANDARD", @@ -57,11 +54,17 @@ ohos_static_library("libhuks_mbedtls_standard_static") { "src/hks_mbedtls_x25519.c", ] - deps = [ - "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static", - "//third_party/mbedtls", - "//third_party/openssl:libcrypto_shared", - ] + deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ] + if (huks_dependency_mbedtls_path != "") { + deps += [ huks_dependency_mbedtls_path ] + } else { + deps += [ "//third_party/mbedtls" ] + } + if (huks_dependency_openssl_path != "") { + deps += [ huks_dependency_openssl_path ] + } else { + deps += [ "//third_party/openssl:libcrypto_shared" ] + } cflags = [ "-DHILOG_ENABLE", "-Wall", diff --git a/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn b/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn index 4433705a..82e2d183 100644 --- a/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn +++ b/frameworks/huks_standard/main/crypto_engine/openssl/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//base/security/huks/build/config.gni") import("//build/ohos.gni") config("huks_config") { @@ -27,8 +28,6 @@ ohos_static_library("libhuks_openssl_standard_static") { part_name = "huks" public_configs = [ ":huks_config" ] - include_dirs = [ "//third_party/openssl/include" ] - defines = [ "L2_STANDARD", "_HARDWARE_ROOT_KEY_", @@ -54,10 +53,12 @@ ohos_static_library("libhuks_openssl_standard_static") { "src/hks_openssl_sm4.c", ] - deps = [ - "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static", - "//third_party/openssl:libcrypto_shared", - ] + deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ] + if (huks_dependency_openssl_path != "") { + deps += [ huks_dependency_openssl_path ] + } else { + deps += [ "//third_party/openssl:libcrypto_shared" ] + } external_deps = [ "c_utils:utils", "hiviewdfx_hilog_native:libhilog", diff --git a/interfaces/innerkits/huks_lite/BUILD.gn b/interfaces/innerkits/huks_lite/BUILD.gn index 208f8afc..eea7bdff 100644 --- a/interfaces/innerkits/huks_lite/BUILD.gn +++ b/interfaces/innerkits/huks_lite/BUILD.gn @@ -191,11 +191,14 @@ if (ohos_kernel_type == "liteos_m") { "//base/security/huks/frameworks/huks_standard/main/common/include", "//base/security/huks/services/huks_standard/huks_engine/main/core/include", ] - + deps = [] if (huks_use_mbedtls == true) { sources += huks_mbedtls_engine_sources - deps = [ "//third_party/mbedtls:mbedtls_static" ] - include_dirs += [ "//third_party/mbedtls" ] + if (huks_dependency_mbedtls_path != "") { + deps += [ huks_dependency_mbedtls_path ] + } else { + deps += [ "//third_party/mbedtls:mbedtls_static" ] + } configs += [ ":mbedtls_engine" ] } @@ -228,10 +231,16 @@ if (ohos_kernel_type == "liteos_m") { if (huks_use_mbedtls == true) { sources += huks_mbedtls_engine_sources - deps += [ - "//build/lite/config/component/openssl:openssl_shared", - "//third_party/mbedtls:mbedtls_shared", - ] + if (huks_dependency_mbedtls_path != "") { + deps += [ huks_dependency_mbedtls_path ] + } else { + deps += [ "//third_party/mbedtls:mbedtls_shared" ] + } + if (huks_dependency_openssl_path != "") { + deps += [ huks_dependency_openssl_path ] + } else { + deps += [ "//build/lite/config/component/openssl:openssl_shared" ] + } configs += [ ":mbedtls_engine" ] }