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 "_HARDWARE_ROOT_KEY_", 35 "_HUKS_LOG_ENABLE_", 36 "L2_STANDARD", 37 ] 38 if (huks_enable_upgrade_key) { 39 defines += [ "HKS_ENABLE_UPGRADE_KEY" ] 40 41 if (huks_enable_upgrade_derive_key_alg) { 42 # enable upgrade key derivation algorithm from PBKDF2 to HKDF 43 defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ] 44 } 45 } 46 if (enable_user_auth_framework) { 47 cflags += [ "-DHKS_SUPPORT_USER_AUTH_ACCESS_CONTROL" ] 48 } 49 if (enable_bundle_framework) { 50 cflags += [ "-DHKS_SUPPORT_GET_BUNDLE_INFO" ] 51 } 52} 53 54config("l1_small_common_config") { 55 cflags = [] 56 cflags += [ 57 "-DHKS_KEY_VERSION=${huks_key_version}", 58 "-Wall", 59 "-Werror", 60 "-fPIC", 61 ] 62 if (huks_use_hardware_root_key == true) { 63 cflags += [ "-D_HARDWARE_ROOT_KEY_" ] 64 } 65 if (huks_config_file != "") { 66 print(huks_config_file) 67 cflags += [ "-DHKS_CONFIG_FILE=\"${huks_config_file}\"" ] 68 } 69 70 cflags += [ "-DGET_DEV_UDID_ENABLE" ] 71 72 defines = [ 73 "_HUKS_LOG_ENABLE_", 74 "HKS_L1_SMALL", 75 ] 76 if (huks_enable_upgrade_key) { 77 defines += [ "HKS_ENABLE_UPGRADE_KEY" ] 78 79 if (huks_enable_upgrade_small_to_service) { 80 # enable upgrade key for huks transformed to service in small device 81 defines += [ "HKS_ENABLE_SMALL_TO_SERVICE" ] 82 83 if (!hks_enable_test) { 84 # enable if old path is empty stop upgrade operation for small_to_service 85 defines += [ "HKS_ENABLE_MARK_CLEARED_FOR_SMALL_TO_SERVICE" ] 86 } 87 } 88 89 if (huks_enable_upgrade_derive_key_alg) { 90 # enable upgrade key derivation algorithm from PBKDF2 to HKDF 91 defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ] 92 } 93 } 94} 95