1# Copyright (c) 2023-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("//build/test.gni")
15
16module_output_path = "certificate_framework/certificate_framework_test"
17
18ohos_unittest("cf_version1_test") {
19  testonly = true
20  module_out_path = module_output_path
21  configs = [
22    "../../../config/build:coverage_flag",
23    "../../../config/build:coverage_flag_cc",
24  ]
25
26  include_dirs = [
27    "./include",
28    "../../../interfaces/innerkits/certificate",
29    "../../../interfaces/innerkits/common",
30    "../../../interfaces/innerkits/include",
31    "../../../frameworks/common/v1.0/inc",
32    "../../../frameworks/core/v1.0/spi",
33    "../../../frameworks/adapter/v1.0/inc",
34  ]
35
36  sources = [
37    "src/cf_mock.cpp",
38    "src/crypto_x509_cert_chain_test.cpp",
39    "src/crypto_x509_cert_chain_test_ex.cpp",
40    "src/crypto_x509_cert_chain_test_part2.cpp",
41    "src/crypto_x509_cert_chain_validator_test.cpp",
42    "src/crypto_x509_cert_crl_collection_test.cpp",
43    "src/crypto_x509_certificate_test.cpp",
44    "src/crypto_x509_certificate_test_part2.cpp",
45    "src/crypto_x509_certificate_test_part3.cpp",
46    "src/crypto_x509_crl_test.cpp",
47    "src/crypto_x509_crl_test_part2.cpp",
48    "src/crypto_x509_test_common.cpp",
49    "src/x509_distinguished_name_test.cpp",
50  ]
51
52  sources += [
53    "../../../frameworks/core/v1.0/certificate/cert_chain_validator.c",
54    "../../../frameworks/core/v1.0/certificate/cert_crl_collection.c",
55    "../../../frameworks/core/v1.0/certificate/cert_crl_common.c",
56    "../../../frameworks/core/v1.0/certificate/x509_cert_chain.c",
57    "../../../frameworks/core/v1.0/certificate/x509_certificate.c",
58    "../../../frameworks/core/v1.0/certificate/x509_crl.c",
59    "../../../frameworks/core/v1.0/certificate/x509_distinguished_name.c",
60  ]
61  sources += [
62    "../../../frameworks/adapter/v1.0/src/certificate_openssl_common.c",
63    "../../../frameworks/adapter/v1.0/src/x509_cert_chain_openssl.c",
64    "../../../frameworks/adapter/v1.0/src/x509_cert_chain_openssl_ex.c",
65    "../../../frameworks/adapter/v1.0/src/x509_cert_chain_validator_openssl.c",
66    "../../../frameworks/adapter/v1.0/src/x509_certificate_openssl.c",
67    "../../../frameworks/adapter/v1.0/src/x509_crl_entry_openssl.c",
68    "../../../frameworks/adapter/v1.0/src/x509_crl_openssl.c",
69    "../../../frameworks/adapter/v1.0/src/x509_distinguished_name_openssl.c",
70  ]
71
72  sources += [
73    "../../../frameworks/common/v1.0/src/cf_blob.c",
74    "../../../frameworks/common/v1.0/src/cf_log.c",
75    "../../../frameworks/common/v1.0/src/cf_object_base.c",
76    "../../../frameworks/common/v1.0/src/utils.c",
77    "src/memory_mock.c",
78  ]
79  cflags = [ "-DHILOG_ENABLE" ]
80
81  ldflags = [
82    "-fPIC",
83    "-Wl,-E",
84    "-Wl,-rpath=/vendor/lib64/hw",
85    "-Wl,--whole-archive",
86    "-Wl,--wrap=ASN1_INTEGER_get",
87    "-Wl,--wrap=ASN1_STRING_get0_data",
88    "-Wl,--wrap=ASN1_STRING_length",
89    "-Wl,--wrap=ASN1_TIME_new",
90    "-Wl,--wrap=ASN1_TIME_normalize",
91    "-Wl,--wrap=ASN1_TYPE_new",
92    "-Wl,--wrap=ASN1_TYPE_set1",
93    "-Wl,--wrap=BIO_ctrl",
94    "-Wl,--wrap=BIO_new",
95    "-Wl,--wrap=BIO_new_mem_buf",
96    "-Wl,--wrap=BN_bin2bn",
97    "-Wl,--wrap=CRYPTO_strdup",
98    "-Wl,--wrap=DeepCopyBlobToBlob",
99    "-Wl,--wrap=DeepCopyDataToBlob",
100    "-Wl,--wrap=DeepCopyDataToOut",
101    "-Wl,--wrap=GENERAL_NAME_get0_value",
102    "-Wl,--wrap=HcfX509CertificateCreate",
103    "-Wl,--wrap=i2d_AUTHORITY_KEYID",
104    "-Wl,--wrap=i2d_ASN1_INTEGER",
105    "-Wl,--wrap=i2d_ASN1_OCTET_STRING",
106    "-Wl,--wrap=i2d_ASN1_TYPE",
107    "-Wl,--wrap=i2d_GENERAL_NAME",
108    "-Wl,--wrap=i2d_X509",
109    "-Wl,--wrap=i2d_X509_bio",
110    "-Wl,--wrap=i2d_X509_CRL",
111    "-Wl,--wrap=i2d_X509_EXTENSIONS",
112    "-Wl,--wrap=i2d_X509_REVOKED",
113    "-Wl,--wrap=i2d_PUBKEY",
114    "-Wl,--wrap=OBJ_obj2nid",
115    "-Wl,--wrap=OBJ_nid2obj",
116    "-Wl,--wrap=OBJ_nid2sn",
117    "-Wl,--wrap=OBJ_obj2txt",
118    "-Wl,--wrap=OCSP_REQUEST_new",
119    "-Wl,--wrap=OSSL_HTTP_parse_url",
120    "-Wl,--wrap=OBJ_txt2nid",
121    "-Wl,--wrap=OPENSSL_sk_deep_copy",
122    "-Wl,--wrap=OPENSSL_sk_num",
123    "-Wl,--wrap=OPENSSL_sk_value",
124    "-Wl,--wrap=OPENSSL_sk_new_null",
125    "-Wl,--wrap=OPENSSL_sk_push",
126    "-Wl,--wrap=X509_ALGOR_get0",
127    "-Wl,--wrap=X509_check_host",
128    "-Wl,--wrap=X509_CRL_load_http",
129    "-Wl,--wrap=X509_dup",
130    "-Wl,--wrap=X509_get_pubkey",
131    "-Wl,--wrap=X509_get_ext",
132    "-Wl,--wrap=X509_get_ext_d2i",
133    "-Wl,--wrap=X509_get0_serialNumber",
134    "-Wl,--wrap=X509_get1_ocsp",
135    "-Wl,--wrap=X509_getm_notBefore",
136    "-Wl,--wrap=X509_getm_notAfter",
137    "-Wl,--wrap=X509_NAME_add_entry_by_NID",
138    "-Wl,--wrap=X509_NAME_get0_der",
139    "-Wl,--wrap=X509_NAME_new",
140    "-Wl,--wrap=X509_NAME_oneline",
141    "-Wl,--wrap=X509_print",
142    "-Wl,--wrap=X509_STORE_add_cert",
143    "-Wl,--wrap=X509_STORE_CTX_new",
144    "-Wl,--wrap=X509_STORE_new",
145    "-Wl,--wrap=X509_STORE_CTX_init",
146    "-Wl,--wrap=X509_verify",
147    "-Wl,--wrap=X509_verify_cert",
148    "-Wl,--wrap=X509V3_EXT_d2i",
149    "-Wl,--wrap=PKCS12_parse",
150    "-Wl,--wrap=CheckIsSelfSigned",
151  ]
152
153  if (target_cpu == "arm") {
154    cflags += [ "-DBINDER_IPC_32BIT" ]
155  }
156
157  defines = [ "HILOG_ENABLE" ]
158
159  deps = []
160
161  external_deps = [
162    "c_utils:utils",
163    "crypto_framework:crypto_framework_lib",
164    "googletest:gmock",
165    "hilog:libhilog",
166    "openssl:libcrypto_shared",
167    "openssl:libssl_shared",
168  ]
169}
170