• 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    if (huks_use_rkc_in_standard) {
59      defines += [ "HKS_USE_RKC_IN_STANDARD" ]
60
61      include_dirs += [
62        "//base/security/huks/services/huks_standard/huks_service/main/core/include",
63        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/include",
64        "//base/security/huks/services/huks_standard/huks_service/main/upgrade/lock/include",
65      ]
66      sources += [
67        "../rkc/src/hks_rkc.c",
68        "../rkc/src/hks_rkc_rw.c",
69        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_lock.c",
70        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage.c",
71        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_file_lock.c",
72        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_manager.c",
73        "//base/security/huks/services/huks_standard/huks_service/main/hks_storage/src/hks_storage_utils.c",
74        "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/posix/hks_rwlock.c",
75      ]
76
77      # 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
78      if (huks_enable_hdi_in_standard) {
79        sources += [ "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_hdi_access.c" ]
80        external_deps += [ "drivers_interface_huks:libhuks_proxy_1.1" ]
81      } else {
82        sources += [
83          "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_access.c",
84          "//base/security/huks/services/huks_standard/huks_service/main/os_dependency/idl/passthrough/huks_core_dynamic_hal.c",
85        ]
86      }
87
88      deps += [
89        "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static",
90        "//base/security/huks/utils/file_operator:libhuks_utils_file_operator_static",
91        "//base/security/huks/utils/mutex:libhuks_utils_mutex_static",
92      ]
93
94      if (huks_enable_upgrade_rkc_v1tov2) {
95        defines += [ "HKS_ENABLE_UPGRADE_RKC_DERIVE_ALG" ]
96        sources += [ "../rkc/src/hks_rkc_v1.c" ]
97      }
98    }
99
100    deps += [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_standard_static" ]
101
102    complete_static_lib = true
103
104    branch_protector_ret = "pac_ret"
105
106    sanitize = {
107      integer_overflow = true
108      cfi = true
109      debug = false
110      cfi_cross_dso = true
111      boundary_sanitize = true
112      ubsan = true
113    }
114    external_deps = [
115      "c_utils:utils",
116      "hilog:libhilog",
117    ]
118    if (huks_dependency_openssl_path != "") {
119      deps += [ huks_dependency_openssl_path ]
120    } else {
121      external_deps += [ "openssl:libcrypto_shared" ]
122    }
123    configs = [
124      "//base/security/huks/frameworks/config/build:l2_standard_common_config",
125    ]
126  }
127} else {
128  ohos_static_library("libhuks_openssl_small_static") {
129    include_dirs = [ "../crypto_common/include" ]
130    sources = [
131      "src/hks_openssl_ability.c",
132      "src/hks_openssl_aes.c",
133      "src/hks_openssl_bn.c",
134      "src/hks_openssl_common.c",
135      "src/hks_openssl_curve25519.c",
136      "src/hks_openssl_dh.c",
137      "src/hks_openssl_dsa.c",
138      "src/hks_openssl_ecc.c",
139      "src/hks_openssl_ed25519tox25519.c",
140      "src/hks_openssl_engine.c",
141      "src/hks_openssl_hash.c",
142      "src/hks_openssl_hmac.c",
143      "src/hks_openssl_kdf.c",
144      "src/hks_openssl_rsa.c",
145      "src/hks_openssl_sm2.c",
146      "src/hks_openssl_sm3.c",
147      "src/hks_openssl_sm4.c",
148    ]
149
150    deps = [ "//base/security/huks/frameworks/huks_standard/main/common:libhuks_common_small_static" ]
151
152    complete_static_lib = true
153
154    external_deps = [ "hilog_lite:hilog_shared" ]
155    if (huks_dependency_openssl_path != "") {
156      deps += [ huks_dependency_openssl_path ]
157    } else {
158      deps += [ "//build/lite/config/component/openssl:openssl_shared" ]
159    }
160    configs = [
161      "//base/security/huks/frameworks/config/build:l1_small_common_config",
162    ]
163  }
164}
165