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/huks.gni") 15import("//build/ohos.gni") 16import("//build/test.gni") 17 18module_output_path = "huks_standard/hal_unittest" 19 20config("json_config") { 21 cflags_cc = [ "-fexceptions" ] 22} 23 24ohos_unittest("crypto_engine_unit_test") { 25 module_out_path = module_output_path 26 include_dirs = [ 27 ".", 28 "include", 29 "//base/security/huks/frameworks/huks_standard/main/common/include", 30 "//base/security/huks/interfaces/innerkits/huks_standard/main/include", 31 ] 32 33 sources = [ 34 "./src/hks_crypto_hal_aes_cipher.cpp", 35 "./src/hks_crypto_hal_aes_decrypt.cpp", 36 "./src/hks_crypto_hal_aes_encrypt.cpp", 37 "./src/hks_crypto_hal_aes_key.cpp", 38 "./src/hks_crypto_hal_common.cpp", 39 "./src/hks_crypto_hal_common.h", 40 "./src/hks_crypto_hal_dh.cpp", 41 "./src/hks_crypto_hal_dh_agree.cpp", 42 "./src/hks_crypto_hal_dsa_key.cpp", 43 "./src/hks_crypto_hal_dsa_sign.cpp", 44 "./src/hks_crypto_hal_ecc_key.cpp", 45 "./src/hks_crypto_hal_ecdh_agree.cpp", 46 "./src/hks_crypto_hal_ecdsa_sign.cpp", 47 "./src/hks_crypto_hal_hmac_hmac.cpp", 48 "./src/hks_crypto_hal_hmac_key.cpp", 49 "./src/hks_crypto_hal_rsa_cipher.cpp", 50 "./src/hks_crypto_hal_rsa_decrypt.cpp", 51 "./src/hks_crypto_hal_rsa_encrypt.cpp", 52 "./src/hks_crypto_hal_rsa_key.cpp", 53 "./src/hks_crypto_hal_rsa_oaep_decrypt.cpp", 54 "./src/hks_crypto_hal_rsa_oaep_encrypt.cpp", 55 "./src/hks_crypto_hal_rsa_sign.cpp", 56 ] 57 if (use_crypto_lib == "openssl") { 58 sources += [ "./src/hks_crypto_hal_api_openssl.cpp" ] 59 } 60 if (use_crypto_lib == "mbedtls") { 61 sources += [ "./src/hks_crypto_hal_api_mbedtls.cpp" ] 62 } 63 64 defines = [ "_HUKS_LOG_ENABLE_" ] 65 66 if (use_crypto_lib == "openssl") { 67 defines += [ "_USE_OPENSSL_" ] 68 } 69 if (use_crypto_lib == "mbedtls") { 70 defines += [ "_USE_MBEDTLS_" ] 71 } 72 73 configs = [ 74 "//commonlibrary/c_utils/base:utils_config", 75 "//base/security/huks/frameworks/config/build:coverage_flag", 76 ] 77 78 deps = [ 79 "//base/security/huks/frameworks/huks_standard/main/os_dependency:libhuks_os_dependency_standard_static", 80 "//third_party/googletest:gtest_main", 81 ] 82 external_deps = [ 83 "c_utils:utils", 84 "hiviewdfx_hilog_native:libhilog", 85 ] 86 87 cflags = [ 88 "-Wall", 89 "-Werror", 90 ] 91 92 if (use_crypto_lib == "openssl") { 93 deps += [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/openssl:libhuks_openssl_standard_static" ] 94 } 95 if (use_crypto_lib == "mbedtls") { 96 deps += [ "//base/security/huks/frameworks/huks_standard/main/crypto_engine/mbedtls:libhuks_mbedtls_standard_static" ] 97 } 98 99 subsystem_name = "security" 100 part_name = "huks" 101} 102