1# Copyright (C) 2022-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/crypto_framework/common/common.gni") 15import("//base/security/crypto_framework/frameworks/frameworks.gni") 16import("//base/security/crypto_framework/plugin/plugin.gni") 17import("//build/test.gni") 18 19module_output_path = "crypto_framework/crypto_framework_test" 20 21ohos_unittest("crypto_framework_test") { 22 testonly = true 23 module_out_path = module_output_path 24 25 include_dirs = [ "./include" ] 26 include_dirs += [ 27 "../../plugin/openssl_plugin/key/asy_key_generator/src", 28 "../../plugin/openssl_plugin/crypto_operation/signature/src", 29 "../../interfaces/innerkits/key/", 30 "../../interfaces/kits/native/include/", 31 ] 32 include_dirs += 33 framework_inc_path + plugin_inc_path + crypto_framwork_common_inc_path 34 35 sources = [ 36 "src/aes_cipher/aes_common.cpp", 37 "src/aes_cipher/crypto_aes_cbc_cipher_test.cpp", 38 "src/aes_cipher/crypto_aes_ccm_cipher_test.cpp", 39 "src/aes_cipher/crypto_aes_cfb_cipher_test.cpp", 40 "src/aes_cipher/crypto_aes_cipher_test.cpp", 41 "src/aes_cipher/crypto_aes_ctr_cipher_test.cpp", 42 "src/aes_cipher/crypto_aes_ecb_cipher_test.cpp", 43 "src/aes_cipher/crypto_aes_gcm_cipher_test.cpp", 44 "src/aes_cipher/crypto_aes_ofb_cipher_test.cpp", 45 "src/crypto_3des_cipher_test.cpp", 46 "src/crypto_asy_key_generator_cov_test.cpp", 47 "src/crypto_brainpool_asy_key_generator_test.cpp", 48 "src/crypto_brainpool_key_agreement_test.cpp", 49 "src/crypto_brainpool_no_length_sign_test.cpp", 50 "src/crypto_brainpool_no_length_verify_test.cpp", 51 "src/crypto_common_cov_test.cpp", 52 "src/crypto_dh_asy_key_generator_by_spec_test.cpp", 53 "src/crypto_dh_asy_key_generator_test.cpp", 54 "src/crypto_dh_key_agreement_test.cpp", 55 "src/crypto_dsa_asy_key_generator_by_spec_test.cpp", 56 "src/crypto_dsa_asy_key_generator_test.cpp", 57 "src/crypto_dsa_exception_test.cpp", 58 "src/crypto_dsa_sign_test.cpp", 59 "src/crypto_dsa_verify_test.cpp", 60 "src/crypto_ecc_asy_key_generator_test.cpp", 61 "src/crypto_ecc_key_agreement_by_spec_test.cpp", 62 "src/crypto_ecc_key_agreement_test.cpp", 63 "src/crypto_ecc_key_util_test.cpp", 64 "src/crypto_ed25519_asy_key_generator_by_spec_test.cpp", 65 "src/crypto_ed25519_asy_key_generator_test.cpp", 66 "src/crypto_ed25519_sign_test.cpp", 67 "src/crypto_ed25519_verify_test.cpp", 68 "src/crypto_hkdf_test.cpp", 69 "src/crypto_key_utils_test.cpp", 70 "src/crypto_mac_test.cpp", 71 "src/crypto_md_sm3_test.cpp", 72 "src/crypto_md_test.cpp", 73 "src/crypto_openssl_common_test.cpp", 74 "src/crypto_pbkdf2_test.cpp", 75 "src/crypto_rand_test.cpp", 76 "src/crypto_rsa1024_asy_key_generator_by_spec_test.cpp", 77 "src/crypto_rsa2048_asy_key_generator_by_spec_test.cpp", 78 "src/crypto_rsa3072_asy_key_generator_by_spec_test.cpp", 79 "src/crypto_rsa4096_asy_key_generator_by_spec_test.cpp", 80 "src/crypto_rsa512_asy_key_generator_by_spec_test.cpp", 81 "src/crypto_rsa768_asy_key_generator_by_spec_test.cpp", 82 "src/crypto_rsa8192_asy_key_generator_by_spec_test.cpp", 83 "src/crypto_rsa_asy_key_generator_by_spec_cov_test.cpp", 84 "src/crypto_rsa_asy_key_generator_test.cpp", 85 "src/crypto_rsa_asy_key_pem_test.cpp", 86 "src/crypto_rsa_cipher_sub_test.cpp", 87 "src/crypto_rsa_cipher_test.cpp", 88 "src/crypto_rsa_only_sign_and_verify_recover_test.cpp", 89 "src/crypto_rsa_sign_test.cpp", 90 "src/crypto_rsa_verify_test.cpp", 91 "src/crypto_signature_exception_test.cpp", 92 "src/crypto_sm2_asy_key_generator_test.cpp", 93 "src/crypto_sm2_cipher_test.cpp", 94 "src/crypto_sm2_sign_test.cpp", 95 "src/crypto_sm2_verify_test.cpp", 96 "src/crypto_sm3_mac_test.cpp", 97 "src/crypto_sm4_cfb_cipher_test.cpp", 98 "src/crypto_sm4_cipher_test.cpp", 99 "src/crypto_sm4_ecb_cipher_test.cpp", 100 "src/crypto_sm4_gcm_cipher_test.cpp", 101 "src/crypto_sm4_generator_test.cpp", 102 "src/crypto_x25519_asy_key_generator_by_spec_test.cpp", 103 "src/crypto_x25519_asy_key_generator_test.cpp", 104 "src/crypto_x25519_key_agreement_test.cpp", 105 "src/ecc/crypto_ecc_asy_key_generator_by_spec_sub_four_test.cpp", 106 "src/ecc/crypto_ecc_asy_key_generator_by_spec_sub_one_test.cpp", 107 "src/ecc/crypto_ecc_asy_key_generator_by_spec_sub_three_test.cpp", 108 "src/ecc/crypto_ecc_asy_key_generator_by_spec_sub_two_test.cpp", 109 "src/ecc/crypto_ecc_asy_key_generator_by_spec_test.cpp", 110 "src/ecc/crypto_ecc_ecdh_pub_test.cpp", 111 "src/ecc/crypto_ecc_no_length_sign_sub_test.cpp", 112 "src/ecc/crypto_ecc_no_length_sign_test.cpp", 113 "src/ecc/crypto_ecc_no_length_verify_sub_test.cpp", 114 "src/ecc/crypto_ecc_no_length_verify_test.cpp", 115 "src/ecc/crypto_ecc_sign_sub_test.cpp", 116 "src/ecc/crypto_ecc_sign_test.cpp", 117 "src/ecc/crypto_ecc_verify_sub_test.cpp", 118 "src/ecc/crypto_ecc_verify_test.cpp", 119 "src/native/native_asym_key_test.cpp", 120 "src/native/native_digest_test.cpp", 121 "src/native/native_signature_test.cpp", 122 "src/native/native_sym_cipher_test.cpp", 123 "src/native/native_sym_key_test.cpp", 124 "src/sm2/crypto_sm2_asy_key_generator_by_spec_sub_test.cpp", 125 "src/sm2/crypto_sm2_asy_key_generator_by_spec_test.cpp", 126 "src/sm2/crypto_sm2_util_test.cpp", 127 ] 128 129 sources += framework_files + plugin_files 130 sources -= [ "//base/security/crypto_framework/plugin/openssl_plugin/common/src/openssl_adapter.c" ] 131 sources -= [ "//base/security/crypto_framework/plugin/openssl_plugin/key/asy_key_generator/src/dsa_asy_key_generator_openssl.c" ] 132 sources -= [ "//base/security/crypto_framework/plugin/openssl_plugin/crypto_operation/signature/src/dsa_openssl.c" ] 133 sources -= [ "//base/security/crypto_framework/plugin/openssl_plugin/crypto_operation/signature/src/signature_rsa_openssl.c" ] 134 sources += [ 135 "//base/security/crypto_framework/common/src/asy_key_params.c", 136 "//base/security/crypto_framework/common/src/blob.c", 137 "//base/security/crypto_framework/common/src/hcf_parcel.c", 138 "//base/security/crypto_framework/common/src/hcf_string.c", 139 "//base/security/crypto_framework/common/src/log.c", 140 "//base/security/crypto_framework/common/src/object_base.c", 141 "//base/security/crypto_framework/common/src/params_parser.c", 142 "//base/security/crypto_framework/common/src/utils.c", 143 "src/alg_25519_common_param_spec.c", 144 "src/ecc/ecc_asy_key_common.cpp", 145 "src/ecc_common_param_spec.c", 146 "src/memory_mock.c", 147 "src/openssl_adapter_mock.c", 148 "src/rsa_common_param_spec.cpp", 149 "src/sm4_common.cpp", 150 ] 151 cflags = [ "-DHILOG_ENABLE" ] 152 if (target_cpu == "arm") { 153 cflags += [ "-DBINDER_IPC_32BIT" ] 154 } 155 156 deps = [ 157 "../../frameworks/native:ohcrypto", 158 "../../plugin:crypto_openssl_plugin_lib", 159 ] 160 161 defines = [ 162 "HILOG_ENABLE", 163 "OPENSSL_SUPPRESS_DEPRECATED", 164 ] 165 166 external_deps = [ 167 "bounds_checking_function:libsec_shared", 168 "c_utils:utils", 169 "hilog:libhilog", 170 "openssl:libcrypto_shared", 171 ] 172} 173