• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//base/security/huks/build/config.gni")
15import("//base/security/huks/huks.gni")
16import("//build/ohos.gni")
17
18if (os_level == "standard") {
19  config("huks_config") {
20    include_dirs = [
21      "include",
22      "../crypto_common/include",
23    ]
24    if (huks_use_rkc_in_standard) {
25      include_dirs += [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/rkc/include" ]
26    }
27    defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
28  }
29  ohos_static_library("libhuks_openssl_standard_static") {
30    subsystem_name = "security"
31    part_name = "huks"
32    public_configs = [ ":huks_config" ]
33
34    sources = [
35      "src/hks_openssl_3des.c",
36      "src/hks_openssl_ability.c",
37      "src/hks_openssl_aes.c",
38      "src/hks_openssl_bn.c",
39      "src/hks_openssl_common.c",
40      "src/hks_openssl_curve25519.c",
41      "src/hks_openssl_des.c",
42      "src/hks_openssl_dh.c",
43      "src/hks_openssl_dsa.c",
44      "src/hks_openssl_ecc.c",
45      "src/hks_openssl_ed25519tox25519.c",
46      "src/hks_openssl_engine.c",
47      "src/hks_openssl_hash.c",
48      "src/hks_openssl_hmac.c",
49      "src/hks_openssl_kdf.c",
50      "src/hks_openssl_rsa.c",
51      "src/hks_openssl_sm2.c",
52      "src/hks_openssl_sm3.c",
53      "src/hks_openssl_sm4.c",
54    ]
55    deps = []
56    defines = []
57    include_dirs = []
58    external_deps = []
59    if (huks_use_rkc_in_standard) {
60      defines += [ "HKS_USE_RKC_IN_STANDARD" ]
61
62      include_dirs += [
63        "//base/security/huks/services/huks_standard/huks_service/main/core/include",
64        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
65        "//base/security/huks/services/huks_standard/huks_service/main/upgrade/lock/include",
66      ]
67      sources += [
68        "../rkc/src/hks_rkc.c",
69        "../rkc/src/hks_rkc_rw.c",
70        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c",
71        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
72        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
73        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
74        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
75        "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c",
76      ]
77
78      # when uks_use_rkc_in_standard and HKS_ENABLE_CLEAN_FILE are enabled at the same time, add the dependency of HDI to the engine
79      if (huks_enable_hdi_in_standard) {
80        sources += [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_hdi_access.c" ]
81        external_deps += [ "drivers_interface_huks:libhuks_proxy_1.1" ]
82      } else {
83        sources += [
84          "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_access.c",
85          "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_core_dynamic_hal.c",
86        ]
87      }
88
89      deps += [
90        "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static",
91        "//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static",
92        "//base/security/huks/utils/mutex:libhuks_utils_mutex_static",
93      ]
94
95      if (huks_enable_upgrade_rkc_v1tov2) {
96        defines += [ "HKS_ENABLE_UPGRADE_RKC_DERIVE_ALG" ]
97        sources += [ "../rkc/src/hks_rkc_v1.c" ]
98      }
99    }
100
101    deps += [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ]
102
103    complete_static_lib = true
104
105    branch_protector_ret = "pac_ret"
106
107    sanitize = {
108      integer_overflow = true
109      cfi = true
110      debug = false
111      cfi_cross_dso = true
112      boundary_sanitize = true
113      ubsan = true
114    }
115    external_deps += [
116      "c_utils:utils",
117      "hilog:libhilog",
118    ]
119    if (huks_dependency_openssl_path != "") {
120      deps += [ huks_dependency_openssl_path ]
121    } else {
122      external_deps += [ "openssl:libcrypto_shared" ]
123    }
124    configs = [
125      "//base/security/huks/frameworks/config/build:l2_standard_common_config",
126    ]
127  }
128} else {
129  ohos_static_library("libhuks_openssl_small_static") {
130    include_dirs = [ "../crypto_common/include" ]
131    sources = [
132      "src/hks_openssl_ability.c",
133      "src/hks_openssl_aes.c",
134      "src/hks_openssl_bn.c",
135      "src/hks_openssl_common.c",
136      "src/hks_openssl_curve25519.c",
137      "src/hks_openssl_dh.c",
138      "src/hks_openssl_dsa.c",
139      "src/hks_openssl_ecc.c",
140      "src/hks_openssl_ed25519tox25519.c",
141      "src/hks_openssl_engine.c",
142      "src/hks_openssl_hash.c",
143      "src/hks_openssl_hmac.c",
144      "src/hks_openssl_kdf.c",
145      "src/hks_openssl_rsa.c",
146      "src/hks_openssl_sm2.c",
147      "src/hks_openssl_sm3.c",
148      "src/hks_openssl_sm4.c",
149    ]
150
151    deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_small_static" ]
152
153    complete_static_lib = true
154
155    external_deps = [ "hilog_lite:hilog_shared" ]
156    if (huks_dependency_openssl_path != "") {
157      deps += [ huks_dependency_openssl_path ]
158    } else {
159      deps += [ "//build/lite/config/component/openssl:openssl_shared" ]
160    }
161    configs = [
162      "//base/security/huks/frameworks/config/build:l1_small_common_config",
163    ]
164  }
165}
166