• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021-2022 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")
16
17config("l2_standard_common_config") {
18  cflags = []
19  if (enable_hks_coverage) {
20    cflags += [ "--coverage" ]
21    ldflags = [ "--coverage" ]
22  }
23  cflags += [
24    "-DHKS_KEY_VERSION=${huks_key_version}",
25    "-Wall",
26    "-Werror",
27    "-fPIC",
28  ]
29
30  cflags +=
31      [ "-DHKS_CONFIG_KEY_STORE_PATH=\"${huks_key_store_standard_path}\"" ]
32
33  defines = [
34    "_HUKS_LOG_ENABLE_",
35    "L2_STANDARD",
36  ]
37  if (!huks_use_rkc_in_standard) {
38    defines += [ "_HARDWARE_ROOT_KEY_" ]
39  }
40  if (huks_enable_upgrade_key) {
41    defines += [ "HKS_ENABLE_UPGRADE_KEY" ]
42
43    if (huks_enable_upgrade_derive_key_alg) {
44      # enable upgrade key derivation algorithm from PBKDF2 to HKDF
45      defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ]
46    }
47  }
48  if (enable_user_auth_framework) {
49    cflags += [ "-DHKS_SUPPORT_USER_AUTH_ACCESS_CONTROL" ]
50  }
51  if (enable_bundle_framework) {
52    cflags += [ "-DHKS_SUPPORT_GET_BUNDLE_INFO" ]
53  }
54  if (huks_use_rkc_in_standard) {
55    cflags +=
56        [ "-DHKS_CONFIG_RKC_STORE_PATH=\"${huks_use_rkc_in_standard_path}\"" ]
57    defines += [ "HKS_USE_RKC_IN_STANDARD" ]
58  }
59}
60
61config("l1_small_common_config") {
62  cflags = []
63  cflags += [
64    "-DHKS_KEY_VERSION=${huks_key_version}",
65    "-Wall",
66    "-Werror",
67    "-fPIC",
68  ]
69  if (huks_use_hardware_root_key == true) {
70    cflags += [ "-D_HARDWARE_ROOT_KEY_" ]
71  }
72  if (huks_config_file != "") {
73    print(huks_config_file)
74    cflags += [ "-DHKS_CONFIG_FILE=\"${huks_config_file}\"" ]
75  }
76
77  cflags += [ "-DGET_DEV_UDID_ENABLE" ]
78
79  defines = [
80    "_HUKS_LOG_ENABLE_",
81    "HKS_L1_SMALL",
82  ]
83  if (huks_enable_upgrade_key) {
84    defines += [ "HKS_ENABLE_UPGRADE_KEY" ]
85
86    if (huks_enable_upgrade_small_to_service) {
87      # enable upgrade key for huks transformed to service in small device
88      defines += [ "HKS_ENABLE_SMALL_TO_SERVICE" ]
89
90      if (!hks_enable_test) {
91        # enable if old path is empty stop upgrade operation for small_to_service
92        defines += [ "HKS_ENABLE_MARK_CLEARED_FOR_SMALL_TO_SERVICE" ]
93      }
94    }
95
96    if (huks_enable_upgrade_derive_key_alg) {
97      # enable upgrade key derivation algorithm from PBKDF2 to HKDF
98      defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ]
99    }
100  }
101}
102