支持产品替换MbedTls和OpenSSL

Signed-off-by: zhangwenzhi <zhangwenzhi3@huawei.com>
This commit is contained in:
CheungVane 2022-11-08 19:06:45 +08:00
parent 09cd0567be
commit 4802e97ac7
4 changed files with 42 additions and 23 deletions

View File

@ -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 = ""
}

View File

@ -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",

View File

@ -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",

View File

@ -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" ]
}