1526fd984Sopenharmony_ci# Copyright (C) 2021-2022 Huawei Device Co., Ltd. 2526fd984Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License"); 3526fd984Sopenharmony_ci# you may not use this file except in compliance with the License. 4526fd984Sopenharmony_ci# You may obtain a copy of the License at 5526fd984Sopenharmony_ci# 6526fd984Sopenharmony_ci# http://www.apache.org/licenses/LICENSE-2.0 7526fd984Sopenharmony_ci# 8526fd984Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software 9526fd984Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS, 10526fd984Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11526fd984Sopenharmony_ci# See the License for the specific language governing permissions and 12526fd984Sopenharmony_ci# limitations under the License. 13526fd984Sopenharmony_ci 14526fd984Sopenharmony_ciimport("//base/security/huks/build/config.gni") 15526fd984Sopenharmony_ciimport("//base/security/huks/huks.gni") 16526fd984Sopenharmony_ci 17526fd984Sopenharmony_ciconfig("l2_standard_common_config") { 18526fd984Sopenharmony_ci cflags = [] 19526fd984Sopenharmony_ci if (enable_hks_coverage) { 20526fd984Sopenharmony_ci cflags += [ "--coverage" ] 21526fd984Sopenharmony_ci ldflags = [ "--coverage" ] 22526fd984Sopenharmony_ci } 23526fd984Sopenharmony_ci cflags += [ 24526fd984Sopenharmony_ci "-DHKS_KEY_VERSION=${huks_key_version}", 25526fd984Sopenharmony_ci "-Wall", 26526fd984Sopenharmony_ci "-Werror", 27526fd984Sopenharmony_ci "-fPIC", 28526fd984Sopenharmony_ci ] 29526fd984Sopenharmony_ci 30526fd984Sopenharmony_ci cflags += 31526fd984Sopenharmony_ci [ "-DHKS_CONFIG_KEY_STORE_PATH=\"${huks_key_store_standard_path}\"" ] 32526fd984Sopenharmony_ci 33526fd984Sopenharmony_ci defines = [ 34526fd984Sopenharmony_ci "_HUKS_LOG_ENABLE_", 35526fd984Sopenharmony_ci "L2_STANDARD", 36526fd984Sopenharmony_ci "HKS_ENABLE_CLEAN_FILE", 37526fd984Sopenharmony_ci "SUPPORT_STORAGE_BACKUP", 38526fd984Sopenharmony_ci ] 39526fd984Sopenharmony_ci if (!huks_use_rkc_in_standard) { 40526fd984Sopenharmony_ci defines += [ "_HARDWARE_ROOT_KEY_" ] 41526fd984Sopenharmony_ci } 42526fd984Sopenharmony_ci if (huks_enable_upgrade_key) { 43526fd984Sopenharmony_ci defines += [ "HKS_ENABLE_UPGRADE_KEY" ] 44526fd984Sopenharmony_ci 45526fd984Sopenharmony_ci if (huks_enable_upgrade_derive_key_alg) { 46526fd984Sopenharmony_ci # enable upgrade key derivation algorithm from PBKDF2 to HKDF 47526fd984Sopenharmony_ci defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ] 48526fd984Sopenharmony_ci } 49526fd984Sopenharmony_ci } 50526fd984Sopenharmony_ci if (enable_user_auth_framework) { 51526fd984Sopenharmony_ci cflags += [ "-DHKS_SUPPORT_USER_AUTH_ACCESS_CONTROL" ] 52526fd984Sopenharmony_ci } 53526fd984Sopenharmony_ci if (enable_bundle_framework) { 54526fd984Sopenharmony_ci cflags += [ "-DHKS_SUPPORT_GET_BUNDLE_INFO" ] 55526fd984Sopenharmony_ci } 56526fd984Sopenharmony_ci if (huks_use_rkc_in_standard) { 57526fd984Sopenharmony_ci cflags += 58526fd984Sopenharmony_ci [ "-DHKS_CONFIG_RKC_STORE_PATH=\"${huks_use_rkc_in_standard_path}\"" ] 59526fd984Sopenharmony_ci defines += [ "HKS_USE_RKC_IN_STANDARD" ] 60526fd984Sopenharmony_ci } 61526fd984Sopenharmony_ci if (huks_enable_upgrade_key_storage_secure_level) { 62526fd984Sopenharmony_ci defines += [ "HUKS_ENABLE_UPGRADE_KEY_STORAGE_SECURE_LEVEL" ] 63526fd984Sopenharmony_ci cflags += [ 64526fd984Sopenharmony_ci "-DHUKS_SA_UPGRADE_CONFIG=${huks_sa_upgrade_config}", 65526fd984Sopenharmony_ci "-DHUKS_HAP_UPGRADE_CONFIG=${huks_hap_upgrade_config}", 66526fd984Sopenharmony_ci "-DHUKS_SA_SKIP_UPGRADE_CONFIG=${huks_sa_skip_upgrade_config}", 67526fd984Sopenharmony_ci "-DHUKS_HAP_SKIP_UPGRADE_CONFIG=${huks_hap_skip_upgrade_config}", 68526fd984Sopenharmony_ci ] 69526fd984Sopenharmony_ci if (huks_enable_skip_upgrade_key_storage_secure_level) { 70526fd984Sopenharmony_ci defines += [ "HUKS_ENABLE_SKIP_UPGRADE_KEY_STORAGE_SECURE_LEVEL" ] 71526fd984Sopenharmony_ci } 72526fd984Sopenharmony_ci } 73526fd984Sopenharmony_ci} 74526fd984Sopenharmony_ci 75526fd984Sopenharmony_ciconfig("l1_small_common_config") { 76526fd984Sopenharmony_ci cflags = [] 77526fd984Sopenharmony_ci cflags += [ 78526fd984Sopenharmony_ci "-DHKS_KEY_VERSION=${huks_key_version}", 79526fd984Sopenharmony_ci "-Wall", 80526fd984Sopenharmony_ci "-Werror", 81526fd984Sopenharmony_ci "-fPIC", 82526fd984Sopenharmony_ci ] 83526fd984Sopenharmony_ci if (huks_use_hardware_root_key == true) { 84526fd984Sopenharmony_ci cflags += [ "-D_HARDWARE_ROOT_KEY_" ] 85526fd984Sopenharmony_ci } 86526fd984Sopenharmony_ci if (huks_config_file != "") { 87526fd984Sopenharmony_ci print(huks_config_file) 88526fd984Sopenharmony_ci cflags += [ "-DHKS_CONFIG_FILE=\"${huks_config_file}\"" ] 89526fd984Sopenharmony_ci } 90526fd984Sopenharmony_ci 91526fd984Sopenharmony_ci cflags += [ "-DGET_DEV_UDID_ENABLE" ] 92526fd984Sopenharmony_ci 93526fd984Sopenharmony_ci defines = [ 94526fd984Sopenharmony_ci "_HUKS_LOG_ENABLE_", 95526fd984Sopenharmony_ci "HKS_L1_SMALL", 96526fd984Sopenharmony_ci ] 97526fd984Sopenharmony_ci if (huks_enable_upgrade_key) { 98526fd984Sopenharmony_ci defines += [ "HKS_ENABLE_UPGRADE_KEY" ] 99526fd984Sopenharmony_ci 100526fd984Sopenharmony_ci if (huks_enable_upgrade_small_to_service) { 101526fd984Sopenharmony_ci # enable upgrade key for huks transformed to service in small device 102526fd984Sopenharmony_ci defines += [ "HKS_ENABLE_SMALL_TO_SERVICE" ] 103526fd984Sopenharmony_ci 104526fd984Sopenharmony_ci if (!hks_enable_test) { 105526fd984Sopenharmony_ci # enable if old path is empty stop upgrade operation for small_to_service 106526fd984Sopenharmony_ci defines += [ "HKS_ENABLE_MARK_CLEARED_FOR_SMALL_TO_SERVICE" ] 107526fd984Sopenharmony_ci } 108526fd984Sopenharmony_ci } 109526fd984Sopenharmony_ci 110526fd984Sopenharmony_ci if (huks_enable_upgrade_derive_key_alg) { 111526fd984Sopenharmony_ci # enable upgrade key derivation algorithm from PBKDF2 to HKDF 112526fd984Sopenharmony_ci defines += [ "HKS_CHANGE_DERIVE_KEY_ALG_TO_HKDF" ] 113526fd984Sopenharmony_ci } 114526fd984Sopenharmony_ci } 115526fd984Sopenharmony_ci} 116