• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2020-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("//build/ohos.gni")
15
16# Only use this to set/unset some cflags, use "platform" variable in gn template to add
17# source code for Windows.
18
19config("crypto_config") {
20  include_dirs = [
21    "./",
22    "./crypto",
23    "./include",
24    "./crypto/modes",
25    "./crypto/ec/curve448",
26    "./crypto/ec/curve448/arch_32",
27  ]
28  cflags = [
29    "-Wall",
30    "-Wno-implicit-fallthrough",
31    "-pthread",
32    "-fPIC",
33    "-Wa,--noexecstack",
34    "-Qunused-arguments",
35    "-O3",
36    "-DOPENSSL_USE_NODELETE",
37    "-DOPENSSL_PIC",
38    "-DOPENSSLDIR=\"\"",
39    "-DENGINESDIR=\"\"",
40    "-DNDEBUG",
41    "-DOPENSSL_NO_BF",
42    "-DOPENSSL_NO_CAMELLIA",
43    "-DOPENSSL_NO_CAST",
44    "-DOPENSSL_NO_CT",
45    "-DOPENSSL_NO_MD2",
46    "-DOPENSSL_NO_RC5",
47    "-DOPENSSL_NO_RC2",
48    "-DOPENSSL_NO_RIPEMD",
49    "-DOPENSSL_NO_RMD160",
50  ]
51  if (current_cpu == "arm" && !(current_os == "linux" || host_os == "mac")) {
52    cflags += [
53      "-DOPENSSL_CPUID_OBJ",
54      "-DOPENSSL_BN_ASM_MONT",
55      "-DOPENSSL_BN_ASM_GF2m",
56      "-DSHA1_ASM",
57      "-DSHA256_ASM",
58      "-DSHA512_ASM",
59      "-DKECCAK1600_ASM",
60      "-DAES_ASM",
61      "-DBSAES_ASM",
62      "-DGHASH_ASM",
63      "-DECP_NISTZ256_ASM",
64      "-DPOLY1305_ASM",
65    ]
66  } else if (current_cpu == "arm64" &&
67             !(current_os == "linux" || host_os == "mac")) {
68    cflags += [
69      "-DOPENSSL_CPUID_OBJ",
70      "-DOPENSSL_BN_ASM_MONT",
71      "-DSHA1_ASM",
72      "-DSHA256_ASM",
73      "-DSHA512_ASM",
74      "-DKECCAK1600_ASM",
75      "-DVPAES_ASM",
76      "-DECP_NISTZ256_ASM",
77      "-DPOLY1305_ASM",
78    ]
79  } else if (is_mingw) {
80    cflags -= [
81      "-fPIC",
82      "-DOPENSSL_NO_BF",
83      "-DOPENSSL_NO_CAMELLIA",
84      "-DOPENSSL_NO_CAST",
85      "-DOPENSSL_NO_CT",
86      "-DOPENSSL_NO_RC2",
87      "-DOPENSSL_NO_RMD160",
88    ]
89    cflags += [
90      "-m64",
91      "-DL_ENDIAN",
92      "-DUNICODE",
93      "-D_UNICODE",
94      "-DWIN32_LEAN_AND_MEAN",
95      "-D_MT",
96      "-MMD",
97      "-MF",
98      "-c",
99      "-Wno-macro-redefined",
100      "-Wno-constant-conversion",
101      "-Wno-sign-compare",
102      "-Wno-incompatible-pointer-types",
103    ]
104  } else if (current_os == "linux" || host_os == "mac") {
105    cflags -= [
106      "-DOPENSSL_NO_BF",
107      "-DOPENSSL_NO_CAMELLIA",
108      "-DOPENSSL_NO_CAST",
109      "-DOPENSSL_NO_CT",
110      "-DOPENSSL_NO_RC2",
111      "-DOPENSSL_NO_RMD160",
112    ]
113    if (current_os == "linux") {
114      cflags += [ "-m64" ]
115    }
116    cflags += [
117      "-DL_ENDIAN",
118      "-D_REENTRAN",
119      "-MMD",
120      "-MF",
121      "-c",
122    ]
123  } else {
124    cflags += [ "-DOPENSSL_NO_ASM" ]
125  }
126}
127
128config("crypto_config_public") {
129  include_dirs = [ "./include" ]
130
131  if (current_cpu == "arm" && !(current_os == "linux" || host_os == "mac")) {
132    cflags = [ "-DOPENSSL_ARM_PLATFORM" ]
133  } else if (current_cpu == "arm64" &&
134             !(current_os == "linux" || host_os == "mac")) {
135    cflags = [ "-DOPENSSL_ARM64_PLATFORM" ]
136  } else if (is_mingw) {
137    cflags = [ "-DWINDOWS_PLATFORM" ]
138  } else if (current_os == "linux" || host_os == "mac") {
139    cflags = [ "-DMAC_PLATFORM" ]
140  } else {
141    cflags = [ "-DOPENSSL_ARM64_PLATFORM" ]
142  }
143}
144
145ohos_source_set("crypto_source") {
146  sources = [
147    "crypto/aes/aes_cbc.c",
148    "crypto/aes/aes_cfb.c",
149    "crypto/aes/aes_ecb.c",
150    "crypto/aes/aes_ige.c",
151    "crypto/aes/aes_misc.c",
152    "crypto/aes/aes_ofb.c",
153    "crypto/aes/aes_wrap.c",
154    "crypto/aria/aria.c",
155    "crypto/asn1/a_bitstr.c",
156    "crypto/asn1/a_d2i_fp.c",
157    "crypto/asn1/a_digest.c",
158    "crypto/asn1/a_dup.c",
159    "crypto/asn1/a_gentm.c",
160    "crypto/asn1/a_i2d_fp.c",
161    "crypto/asn1/a_int.c",
162    "crypto/asn1/a_mbstr.c",
163    "crypto/asn1/a_object.c",
164    "crypto/asn1/a_octet.c",
165    "crypto/asn1/a_print.c",
166    "crypto/asn1/a_sign.c",
167    "crypto/asn1/a_strex.c",
168    "crypto/asn1/a_strnid.c",
169    "crypto/asn1/a_time.c",
170    "crypto/asn1/a_type.c",
171    "crypto/asn1/a_utctm.c",
172    "crypto/asn1/a_utf8.c",
173    "crypto/asn1/a_verify.c",
174    "crypto/asn1/ameth_lib.c",
175    "crypto/asn1/asn1_err.c",
176    "crypto/asn1/asn1_gen.c",
177    "crypto/asn1/asn1_item_list.c",
178    "crypto/asn1/asn1_lib.c",
179    "crypto/asn1/asn1_par.c",
180    "crypto/asn1/asn_mime.c",
181    "crypto/asn1/asn_moid.c",
182    "crypto/asn1/asn_mstbl.c",
183    "crypto/asn1/asn_pack.c",
184    "crypto/asn1/bio_asn1.c",
185    "crypto/asn1/bio_ndef.c",
186    "crypto/asn1/d2i_pr.c",
187    "crypto/asn1/d2i_pu.c",
188    "crypto/asn1/evp_asn1.c",
189    "crypto/asn1/f_int.c",
190    "crypto/asn1/f_string.c",
191    "crypto/asn1/i2d_pr.c",
192    "crypto/asn1/i2d_pu.c",
193    "crypto/asn1/n_pkey.c",
194    "crypto/asn1/nsseq.c",
195    "crypto/asn1/p5_pbe.c",
196    "crypto/asn1/p5_pbev2.c",
197    "crypto/asn1/p5_scrypt.c",
198    "crypto/asn1/p8_pkey.c",
199    "crypto/asn1/t_bitst.c",
200    "crypto/asn1/t_pkey.c",
201    "crypto/asn1/t_spki.c",
202    "crypto/asn1/tasn_dec.c",
203    "crypto/asn1/tasn_enc.c",
204    "crypto/asn1/tasn_fre.c",
205    "crypto/asn1/tasn_new.c",
206    "crypto/asn1/tasn_prn.c",
207    "crypto/asn1/tasn_scn.c",
208    "crypto/asn1/tasn_typ.c",
209    "crypto/asn1/tasn_utl.c",
210    "crypto/asn1/x_algor.c",
211    "crypto/asn1/x_bignum.c",
212    "crypto/asn1/x_info.c",
213    "crypto/asn1/x_int64.c",
214    "crypto/asn1/x_long.c",
215    "crypto/asn1/x_pkey.c",
216    "crypto/asn1/x_sig.c",
217    "crypto/asn1/x_spki.c",
218    "crypto/asn1/x_val.c",
219    "crypto/async/arch/async_null.c",
220    "crypto/async/arch/async_posix.c",
221    "crypto/async/arch/async_win.c",
222    "crypto/async/async.c",
223    "crypto/async/async_err.c",
224    "crypto/async/async_wait.c",
225    "crypto/bio/b_addr.c",
226    "crypto/bio/b_dump.c",
227    "crypto/bio/b_print.c",
228    "crypto/bio/b_sock.c",
229    "crypto/bio/b_sock2.c",
230    "crypto/bio/bf_buff.c",
231    "crypto/bio/bf_lbuf.c",
232    "crypto/bio/bf_nbio.c",
233    "crypto/bio/bf_null.c",
234    "crypto/bio/bio_cb.c",
235    "crypto/bio/bio_err.c",
236    "crypto/bio/bio_lib.c",
237    "crypto/bio/bio_meth.c",
238    "crypto/bio/bss_acpt.c",
239    "crypto/bio/bss_bio.c",
240    "crypto/bio/bss_conn.c",
241    "crypto/bio/bss_dgram.c",
242    "crypto/bio/bss_fd.c",
243    "crypto/bio/bss_file.c",
244    "crypto/bio/bss_log.c",
245    "crypto/bio/bss_mem.c",
246    "crypto/bio/bss_null.c",
247    "crypto/bio/bss_sock.c",
248    "crypto/blake2/blake2b.c",
249    "crypto/blake2/blake2s.c",
250    "crypto/blake2/m_blake2b.c",
251    "crypto/blake2/m_blake2s.c",
252    "crypto/bn/bn_add.c",
253    "crypto/bn/bn_asm.c",
254    "crypto/bn/bn_blind.c",
255    "crypto/bn/bn_const.c",
256    "crypto/bn/bn_ctx.c",
257    "crypto/bn/bn_depr.c",
258    "crypto/bn/bn_dh.c",
259    "crypto/bn/bn_div.c",
260    "crypto/bn/bn_err.c",
261    "crypto/bn/bn_exp.c",
262    "crypto/bn/bn_exp2.c",
263    "crypto/bn/bn_gcd.c",
264    "crypto/bn/bn_gf2m.c",
265    "crypto/bn/bn_intern.c",
266    "crypto/bn/bn_kron.c",
267    "crypto/bn/bn_lib.c",
268    "crypto/bn/bn_mod.c",
269    "crypto/bn/bn_mont.c",
270    "crypto/bn/bn_mpi.c",
271    "crypto/bn/bn_mul.c",
272    "crypto/bn/bn_nist.c",
273    "crypto/bn/bn_prime.c",
274    "crypto/bn/bn_print.c",
275    "crypto/bn/bn_rand.c",
276    "crypto/bn/bn_recp.c",
277    "crypto/bn/bn_shift.c",
278    "crypto/bn/bn_sqr.c",
279    "crypto/bn/bn_sqrt.c",
280    "crypto/bn/bn_srp.c",
281    "crypto/bn/bn_word.c",
282    "crypto/bn/bn_x931p.c",
283    "crypto/bn/rsa_sup_mul.c",
284    "crypto/buffer/buf_err.c",
285    "crypto/buffer/buffer.c",
286    "crypto/cmac/cm_ameth.c",
287    "crypto/cmac/cm_pmeth.c",
288    "crypto/cmac/cmac.c",
289    "crypto/cms/cms_asn1.c",
290    "crypto/cms/cms_att.c",
291    "crypto/cms/cms_cd.c",
292    "crypto/cms/cms_dd.c",
293    "crypto/cms/cms_enc.c",
294    "crypto/cms/cms_env.c",
295    "crypto/cms/cms_err.c",
296    "crypto/cms/cms_ess.c",
297    "crypto/cms/cms_io.c",
298    "crypto/cms/cms_kari.c",
299    "crypto/cms/cms_lib.c",
300    "crypto/cms/cms_pwri.c",
301    "crypto/cms/cms_sd.c",
302    "crypto/cms/cms_smime.c",
303    "crypto/comp/c_zlib.c",
304    "crypto/comp/comp_err.c",
305    "crypto/comp/comp_lib.c",
306    "crypto/conf/conf_api.c",
307    "crypto/conf/conf_def.c",
308    "crypto/conf/conf_err.c",
309    "crypto/conf/conf_lib.c",
310    "crypto/conf/conf_mall.c",
311    "crypto/conf/conf_mod.c",
312    "crypto/conf/conf_sap.c",
313    "crypto/conf/conf_ssl.c",
314    "crypto/cpt_err.c",
315    "crypto/cryptlib.c",
316    "crypto/ctype.c",
317    "crypto/cversion.c",
318    "crypto/des/cbc_cksm.c",
319    "crypto/des/cbc_enc.c",
320    "crypto/des/cfb64ede.c",
321    "crypto/des/cfb64enc.c",
322    "crypto/des/cfb_enc.c",
323    "crypto/des/des_enc.c",
324    "crypto/des/ecb3_enc.c",
325    "crypto/des/ecb_enc.c",
326    "crypto/des/fcrypt.c",
327    "crypto/des/fcrypt_b.c",
328    "crypto/des/ofb64ede.c",
329    "crypto/des/ofb64enc.c",
330    "crypto/des/ofb_enc.c",
331    "crypto/des/pcbc_enc.c",
332    "crypto/des/qud_cksm.c",
333    "crypto/des/rand_key.c",
334    "crypto/des/set_key.c",
335    "crypto/des/str2key.c",
336    "crypto/des/xcbc_enc.c",
337    "crypto/dh/dh_ameth.c",
338    "crypto/dh/dh_asn1.c",
339    "crypto/dh/dh_check.c",
340    "crypto/dh/dh_depr.c",
341    "crypto/dh/dh_err.c",
342    "crypto/dh/dh_gen.c",
343    "crypto/dh/dh_kdf.c",
344    "crypto/dh/dh_key.c",
345    "crypto/dh/dh_lib.c",
346    "crypto/dh/dh_meth.c",
347    "crypto/dh/dh_pmeth.c",
348    "crypto/dh/dh_prn.c",
349    "crypto/dh/dh_rfc5114.c",
350    "crypto/dh/dh_rfc7919.c",
351    "crypto/dsa/dsa_ameth.c",
352    "crypto/dsa/dsa_asn1.c",
353    "crypto/dsa/dsa_depr.c",
354    "crypto/dsa/dsa_err.c",
355    "crypto/dsa/dsa_gen.c",
356    "crypto/dsa/dsa_key.c",
357    "crypto/dsa/dsa_lib.c",
358    "crypto/dsa/dsa_meth.c",
359    "crypto/dsa/dsa_ossl.c",
360    "crypto/dsa/dsa_pmeth.c",
361    "crypto/dsa/dsa_prn.c",
362    "crypto/dsa/dsa_sign.c",
363    "crypto/dsa/dsa_vrf.c",
364    "crypto/dso/dso_dl.c",
365    "crypto/dso/dso_dlfcn.c",
366    "crypto/dso/dso_err.c",
367    "crypto/dso/dso_lib.c",
368    "crypto/dso/dso_openssl.c",
369    "crypto/dso/dso_vms.c",
370    "crypto/dso/dso_win32.c",
371    "crypto/ebcdic.c",
372    "crypto/ec/curve25519.c",
373    "crypto/ec/curve448/arch_32/f_impl.c",
374    "crypto/ec/curve448/curve448.c",
375    "crypto/ec/curve448/curve448_tables.c",
376    "crypto/ec/curve448/eddsa.c",
377    "crypto/ec/curve448/f_generic.c",
378    "crypto/ec/curve448/scalar.c",
379    "crypto/ec/ec2_oct.c",
380    "crypto/ec/ec2_smpl.c",
381    "crypto/ec/ec_ameth.c",
382    "crypto/ec/ec_asn1.c",
383    "crypto/ec/ec_check.c",
384    "crypto/ec/ec_curve.c",
385    "crypto/ec/ec_cvt.c",
386    "crypto/ec/ec_err.c",
387    "crypto/ec/ec_key.c",
388    "crypto/ec/ec_kmeth.c",
389    "crypto/ec/ec_lib.c",
390    "crypto/ec/ec_mult.c",
391    "crypto/ec/ec_oct.c",
392    "crypto/ec/ec_pmeth.c",
393    "crypto/ec/ec_print.c",
394    "crypto/ec/ecdh_kdf.c",
395    "crypto/ec/ecdh_ossl.c",
396    "crypto/ec/ecdsa_ossl.c",
397    "crypto/ec/ecdsa_sign.c",
398    "crypto/ec/ecdsa_vrf.c",
399    "crypto/ec/eck_prn.c",
400    "crypto/ec/ecp_mont.c",
401    "crypto/ec/ecp_nist.c",
402    "crypto/ec/ecp_nistp224.c",
403    "crypto/ec/ecp_nistp256.c",
404    "crypto/ec/ecp_nistp521.c",
405    "crypto/ec/ecp_nistputil.c",
406    "crypto/ec/ecp_oct.c",
407    "crypto/ec/ecp_smpl.c",
408    "crypto/ec/ecx_meth.c",
409    "crypto/engine/eng_all.c",
410    "crypto/engine/eng_cnf.c",
411    "crypto/engine/eng_ctrl.c",
412    "crypto/engine/eng_dyn.c",
413    "crypto/engine/eng_err.c",
414    "crypto/engine/eng_fat.c",
415    "crypto/engine/eng_init.c",
416    "crypto/engine/eng_lib.c",
417    "crypto/engine/eng_list.c",
418    "crypto/engine/eng_openssl.c",
419    "crypto/engine/eng_pkey.c",
420    "crypto/engine/eng_rdrand.c",
421    "crypto/engine/eng_table.c",
422    "crypto/engine/tb_asnmth.c",
423    "crypto/engine/tb_cipher.c",
424    "crypto/engine/tb_dh.c",
425    "crypto/engine/tb_digest.c",
426    "crypto/engine/tb_dsa.c",
427    "crypto/engine/tb_eckey.c",
428    "crypto/engine/tb_pkmeth.c",
429    "crypto/engine/tb_rand.c",
430    "crypto/engine/tb_rsa.c",
431    "crypto/err/err.c",
432    "crypto/err/err_all.c",
433    "crypto/err/err_prn.c",
434    "crypto/evp/bio_b64.c",
435    "crypto/evp/bio_enc.c",
436    "crypto/evp/bio_md.c",
437    "crypto/evp/bio_ok.c",
438    "crypto/evp/c_allc.c",
439    "crypto/evp/c_alld.c",
440    "crypto/evp/cmeth_lib.c",
441    "crypto/evp/digest.c",
442    "crypto/evp/e_aes.c",
443    "crypto/evp/e_aes_cbc_hmac_sha1.c",
444    "crypto/evp/e_aes_cbc_hmac_sha256.c",
445    "crypto/evp/e_aria.c",
446    "crypto/evp/e_bf.c",
447    "crypto/evp/e_camellia.c",
448    "crypto/evp/e_cast.c",
449    "crypto/evp/e_chacha20_poly1305.c",
450    "crypto/evp/e_des.c",
451    "crypto/evp/e_des3.c",
452    "crypto/evp/e_idea.c",
453    "crypto/evp/e_null.c",
454    "crypto/evp/e_old.c",
455    "crypto/evp/e_rc2.c",
456    "crypto/evp/e_rc4.c",
457    "crypto/evp/e_rc4_hmac_md5.c",
458    "crypto/evp/e_rc5.c",
459    "crypto/evp/e_seed.c",
460    "crypto/evp/e_sm4.c",
461    "crypto/evp/e_xcbc_d.c",
462    "crypto/evp/encode.c",
463    "crypto/evp/evp_cnf.c",
464    "crypto/evp/evp_enc.c",
465    "crypto/evp/evp_err.c",
466    "crypto/evp/evp_key.c",
467    "crypto/evp/evp_lib.c",
468    "crypto/evp/evp_pbe.c",
469    "crypto/evp/evp_pkey.c",
470    "crypto/evp/m_md2.c",
471    "crypto/evp/m_md4.c",
472    "crypto/evp/m_md5.c",
473    "crypto/evp/m_md5_sha1.c",
474    "crypto/evp/m_mdc2.c",
475    "crypto/evp/m_null.c",
476    "crypto/evp/m_ripemd.c",
477    "crypto/evp/m_sha1.c",
478    "crypto/evp/m_sha3.c",
479    "crypto/evp/m_sigver.c",
480    "crypto/evp/m_wp.c",
481    "crypto/evp/names.c",
482    "crypto/evp/p5_crpt.c",
483    "crypto/evp/p5_crpt2.c",
484    "crypto/evp/p_dec.c",
485    "crypto/evp/p_enc.c",
486    "crypto/evp/p_lib.c",
487    "crypto/evp/p_open.c",
488    "crypto/evp/p_seal.c",
489    "crypto/evp/p_sign.c",
490    "crypto/evp/p_verify.c",
491    "crypto/evp/pbe_scrypt.c",
492    "crypto/evp/pmeth_fn.c",
493    "crypto/evp/pmeth_gn.c",
494    "crypto/evp/pmeth_lib.c",
495    "crypto/ex_data.c",
496    "crypto/getenv.c",
497    "crypto/hmac/hm_ameth.c",
498    "crypto/hmac/hm_pmeth.c",
499    "crypto/hmac/hmac.c",
500    "crypto/idea/i_cbc.c",
501    "crypto/idea/i_cfb64.c",
502    "crypto/idea/i_ecb.c",
503    "crypto/idea/i_ofb64.c",
504    "crypto/idea/i_skey.c",
505    "crypto/init.c",
506    "crypto/kdf/hkdf.c",
507    "crypto/kdf/kdf_err.c",
508    "crypto/kdf/scrypt.c",
509    "crypto/kdf/tls1_prf.c",
510    "crypto/lhash/lh_stats.c",
511    "crypto/lhash/lhash.c",
512    "crypto/md4/md4_dgst.c",
513    "crypto/md4/md4_one.c",
514    "crypto/md5/md5_dgst.c",
515    "crypto/md5/md5_one.c",
516    "crypto/mdc2/mdc2_one.c",
517    "crypto/mdc2/mdc2dgst.c",
518    "crypto/mem.c",
519    "crypto/mem_dbg.c",
520    "crypto/mem_sec.c",
521    "crypto/modes/cbc128.c",
522    "crypto/modes/ccm128.c",
523    "crypto/modes/cfb128.c",
524    "crypto/modes/ctr128.c",
525    "crypto/modes/cts128.c",
526    "crypto/modes/gcm128.c",
527    "crypto/modes/ocb128.c",
528    "crypto/modes/ofb128.c",
529    "crypto/modes/wrap128.c",
530    "crypto/modes/xts128.c",
531    "crypto/o_dir.c",
532    "crypto/o_fips.c",
533    "crypto/o_fopen.c",
534    "crypto/o_init.c",
535    "crypto/o_str.c",
536    "crypto/o_time.c",
537    "crypto/objects/o_names.c",
538    "crypto/objects/obj_dat.c",
539    "crypto/objects/obj_err.c",
540    "crypto/objects/obj_lib.c",
541    "crypto/objects/obj_xref.c",
542    "crypto/ocsp/ocsp_asn.c",
543    "crypto/ocsp/ocsp_cl.c",
544    "crypto/ocsp/ocsp_err.c",
545    "crypto/ocsp/ocsp_ext.c",
546    "crypto/ocsp/ocsp_ht.c",
547    "crypto/ocsp/ocsp_lib.c",
548    "crypto/ocsp/ocsp_prn.c",
549    "crypto/ocsp/ocsp_srv.c",
550    "crypto/ocsp/ocsp_vfy.c",
551    "crypto/ocsp/v3_ocsp.c",
552    "crypto/pem/pem_all.c",
553    "crypto/pem/pem_err.c",
554    "crypto/pem/pem_info.c",
555    "crypto/pem/pem_lib.c",
556    "crypto/pem/pem_oth.c",
557    "crypto/pem/pem_pk8.c",
558    "crypto/pem/pem_pkey.c",
559    "crypto/pem/pem_sign.c",
560    "crypto/pem/pem_x509.c",
561    "crypto/pem/pem_xaux.c",
562    "crypto/pem/pvkfmt.c",
563    "crypto/pkcs12/p12_add.c",
564    "crypto/pkcs12/p12_asn.c",
565    "crypto/pkcs12/p12_attr.c",
566    "crypto/pkcs12/p12_crpt.c",
567    "crypto/pkcs12/p12_crt.c",
568    "crypto/pkcs12/p12_decr.c",
569    "crypto/pkcs12/p12_init.c",
570    "crypto/pkcs12/p12_key.c",
571    "crypto/pkcs12/p12_kiss.c",
572    "crypto/pkcs12/p12_mutl.c",
573    "crypto/pkcs12/p12_npas.c",
574    "crypto/pkcs12/p12_p8d.c",
575    "crypto/pkcs12/p12_p8e.c",
576    "crypto/pkcs12/p12_sbag.c",
577    "crypto/pkcs12/p12_utl.c",
578    "crypto/pkcs12/pk12err.c",
579    "crypto/pkcs7/bio_pk7.c",
580    "crypto/pkcs7/pk7_asn1.c",
581    "crypto/pkcs7/pk7_attr.c",
582    "crypto/pkcs7/pk7_doit.c",
583    "crypto/pkcs7/pk7_lib.c",
584    "crypto/pkcs7/pk7_mime.c",
585    "crypto/pkcs7/pk7_smime.c",
586    "crypto/pkcs7/pkcs7err.c",
587    "crypto/poly1305/poly1305.c",
588    "crypto/poly1305/poly1305_ameth.c",
589    "crypto/poly1305/poly1305_pmeth.c",
590    "crypto/rand/drbg_ctr.c",
591    "crypto/rand/drbg_lib.c",
592    "crypto/rand/rand_egd.c",
593    "crypto/rand/rand_err.c",
594    "crypto/rand/rand_lib.c",
595    "crypto/rand/rand_unix.c",
596    "crypto/rand/rand_vms.c",
597    "crypto/rand/rand_win.c",
598    "crypto/rand/randfile.c",
599    "crypto/rc4/rc4_enc.c",
600    "crypto/rc4/rc4_skey.c",
601    "crypto/rsa/rsa_ameth.c",
602    "crypto/rsa/rsa_asn1.c",
603    "crypto/rsa/rsa_chk.c",
604    "crypto/rsa/rsa_crpt.c",
605    "crypto/rsa/rsa_depr.c",
606    "crypto/rsa/rsa_err.c",
607    "crypto/rsa/rsa_gen.c",
608    "crypto/rsa/rsa_lib.c",
609    "crypto/rsa/rsa_meth.c",
610    "crypto/rsa/rsa_mp.c",
611    "crypto/rsa/rsa_none.c",
612    "crypto/rsa/rsa_oaep.c",
613    "crypto/rsa/rsa_ossl.c",
614    "crypto/rsa/rsa_pk1.c",
615    "crypto/rsa/rsa_pmeth.c",
616    "crypto/rsa/rsa_prn.c",
617    "crypto/rsa/rsa_pss.c",
618    "crypto/rsa/rsa_saos.c",
619    "crypto/rsa/rsa_sign.c",
620    "crypto/rsa/rsa_ssl.c",
621    "crypto/rsa/rsa_x931.c",
622    "crypto/rsa/rsa_x931g.c",
623    "crypto/seed/seed.c",
624    "crypto/seed/seed_cbc.c",
625    "crypto/seed/seed_cfb.c",
626    "crypto/seed/seed_ecb.c",
627    "crypto/seed/seed_ofb.c",
628    "crypto/sha/sha1_one.c",
629    "crypto/sha/sha1dgst.c",
630    "crypto/sha/sha256.c",
631    "crypto/sha/sha512.c",
632    "crypto/siphash/siphash.c",
633    "crypto/siphash/siphash_ameth.c",
634    "crypto/siphash/siphash_pmeth.c",
635    "crypto/sm2/sm2_crypt.c",
636    "crypto/sm2/sm2_err.c",
637    "crypto/sm2/sm2_pmeth.c",
638    "crypto/sm2/sm2_sign.c",
639    "crypto/sm3/m_sm3.c",
640    "crypto/sm3/sm3.c",
641    "crypto/sm4/sm4.c",
642    "crypto/srp/srp_lib.c",
643    "crypto/srp/srp_vfy.c",
644    "crypto/stack/stack.c",
645    "crypto/store/loader_file.c",
646    "crypto/store/store_err.c",
647    "crypto/store/store_init.c",
648    "crypto/store/store_lib.c",
649    "crypto/store/store_register.c",
650    "crypto/store/store_strings.c",
651    "crypto/threads_none.c",
652    "crypto/threads_pthread.c",
653    "crypto/threads_win.c",
654    "crypto/ts/ts_asn1.c",
655    "crypto/ts/ts_conf.c",
656    "crypto/ts/ts_err.c",
657    "crypto/ts/ts_lib.c",
658    "crypto/ts/ts_req_print.c",
659    "crypto/ts/ts_req_utils.c",
660    "crypto/ts/ts_rsp_print.c",
661    "crypto/ts/ts_rsp_sign.c",
662    "crypto/ts/ts_rsp_utils.c",
663    "crypto/ts/ts_rsp_verify.c",
664    "crypto/ts/ts_verify_ctx.c",
665    "crypto/txt_db/txt_db.c",
666    "crypto/ui/ui_err.c",
667    "crypto/ui/ui_lib.c",
668    "crypto/ui/ui_null.c",
669    "crypto/ui/ui_openssl.c",
670    "crypto/ui/ui_util.c",
671    "crypto/uid.c",
672    "crypto/whrlpool/wp_block.c",
673    "crypto/whrlpool/wp_dgst.c",
674    "crypto/x509/by_dir.c",
675    "crypto/x509/by_file.c",
676    "crypto/x509/t_crl.c",
677    "crypto/x509/t_req.c",
678    "crypto/x509/t_x509.c",
679    "crypto/x509/x509_att.c",
680    "crypto/x509/x509_cmp.c",
681    "crypto/x509/x509_d2.c",
682    "crypto/x509/x509_def.c",
683    "crypto/x509/x509_err.c",
684    "crypto/x509/x509_ext.c",
685    "crypto/x509/x509_lu.c",
686    "crypto/x509/x509_meth.c",
687    "crypto/x509/x509_obj.c",
688    "crypto/x509/x509_r2x.c",
689    "crypto/x509/x509_req.c",
690    "crypto/x509/x509_set.c",
691    "crypto/x509/x509_trs.c",
692    "crypto/x509/x509_txt.c",
693    "crypto/x509/x509_v3.c",
694    "crypto/x509/x509_vfy.c",
695    "crypto/x509/x509_vpm.c",
696    "crypto/x509/x509cset.c",
697    "crypto/x509/x509name.c",
698    "crypto/x509/x509rset.c",
699    "crypto/x509/x509spki.c",
700    "crypto/x509/x509type.c",
701    "crypto/x509/x_all.c",
702    "crypto/x509/x_attrib.c",
703    "crypto/x509/x_crl.c",
704    "crypto/x509/x_exten.c",
705    "crypto/x509/x_name.c",
706    "crypto/x509/x_pubkey.c",
707    "crypto/x509/x_req.c",
708    "crypto/x509/x_x509.c",
709    "crypto/x509/x_x509a.c",
710    "crypto/x509v3/pcy_cache.c",
711    "crypto/x509v3/pcy_data.c",
712    "crypto/x509v3/pcy_lib.c",
713    "crypto/x509v3/pcy_map.c",
714    "crypto/x509v3/pcy_node.c",
715    "crypto/x509v3/pcy_tree.c",
716    "crypto/x509v3/v3_addr.c",
717    "crypto/x509v3/v3_admis.c",
718    "crypto/x509v3/v3_akey.c",
719    "crypto/x509v3/v3_akeya.c",
720    "crypto/x509v3/v3_alt.c",
721    "crypto/x509v3/v3_asid.c",
722    "crypto/x509v3/v3_bcons.c",
723    "crypto/x509v3/v3_bitst.c",
724    "crypto/x509v3/v3_conf.c",
725    "crypto/x509v3/v3_cpols.c",
726    "crypto/x509v3/v3_crld.c",
727    "crypto/x509v3/v3_enum.c",
728    "crypto/x509v3/v3_extku.c",
729    "crypto/x509v3/v3_genn.c",
730    "crypto/x509v3/v3_ia5.c",
731    "crypto/x509v3/v3_info.c",
732    "crypto/x509v3/v3_int.c",
733    "crypto/x509v3/v3_lib.c",
734    "crypto/x509v3/v3_ncons.c",
735    "crypto/x509v3/v3_pci.c",
736    "crypto/x509v3/v3_pcia.c",
737    "crypto/x509v3/v3_pcons.c",
738    "crypto/x509v3/v3_pku.c",
739    "crypto/x509v3/v3_pmaps.c",
740    "crypto/x509v3/v3_prn.c",
741    "crypto/x509v3/v3_purp.c",
742    "crypto/x509v3/v3_skey.c",
743    "crypto/x509v3/v3_sxnet.c",
744    "crypto/x509v3/v3_tlsf.c",
745    "crypto/x509v3/v3_utl.c",
746    "crypto/x509v3/v3err.c",
747  ]
748
749  if (current_cpu == "arm" && !(current_os == "linux" || host_os == "mac")) {
750    sources += [
751      "crypto/aes/asm/arm32/aes-armv4.S",
752      "crypto/aes/asm/arm32/aesv8-armx.S",
753      "crypto/aes/asm/arm32/bsaes-armv7.S",
754      "crypto/armcap.c",
755      "crypto/armv4cpuid.S",
756      "crypto/bn/armv4-gf2m.S",
757      "crypto/bn/armv4-mont.S",
758      "crypto/chacha/chacha-armv4.S",
759      "crypto/ec/ecp_nistz256-armv4.S",
760      "crypto/ec/ecp_nistz256.c",
761      "crypto/modes/asm/arm32/ghash-armv4.S",
762      "crypto/modes/asm/arm32/ghashv8-armx.S",
763      "crypto/poly1305/poly1305-armv4.S",
764      "crypto/sha/keccak1600-armv4.S",
765      "crypto/sha/sha1-armv4-large.S",
766      "crypto/sha/sha256-armv4.S",
767      "crypto/sha/sha512-armv4.S",
768    ]
769  } else if (current_cpu == "arm64" &&
770             !(current_os == "linux" || host_os == "mac")) {
771    sources += [
772      "crypto/aes/aes_core.c",
773      "crypto/aes/asm/arm64/aesv8-armx.S",
774      "crypto/aes/asm/arm64/vpaes-armv8.S",
775      "crypto/arm64cpuid.S",
776      "crypto/armcap.c",
777      "crypto/bn/armv8-mont.S",
778      "crypto/chacha/chacha-armv8.S",
779      "crypto/ec/ecp_nistz256-armv8.S",
780      "crypto/ec/ecp_nistz256.c",
781      "crypto/modes/asm/arm64/ghashv8-armx.S",
782      "crypto/poly1305/poly1305-armv8.S",
783      "crypto/sha/keccak1600-armv8.S",
784      "crypto/sha/sha1-armv8.S",
785      "crypto/sha/sha256-armv8.S",
786      "crypto/sha/sha512-armv8.S",
787    ]
788  } else if (is_mingw || (current_os == "linux" || host_os == "mac")) {
789    sources += [
790      "crypto/aes/aes_core.c",
791      "crypto/bf/bf_cfb64.c",
792      "crypto/bf/bf_ecb.c",
793      "crypto/bf/bf_enc.c",
794      "crypto/bf/bf_ofb64.c",
795      "crypto/bf/bf_skey.c",
796      "crypto/camellia/camellia.c",
797      "crypto/camellia/cmll_cbc.c",
798      "crypto/camellia/cmll_cfb.c",
799      "crypto/camellia/cmll_ctr.c",
800      "crypto/camellia/cmll_ecb.c",
801      "crypto/camellia/cmll_misc.c",
802      "crypto/camellia/cmll_ofb.c",
803      "crypto/cast/c_cfb64.c",
804      "crypto/cast/c_ecb.c",
805      "crypto/cast/c_enc.c",
806      "crypto/cast/c_ofb64.c",
807      "crypto/cast/c_skey.c",
808      "crypto/chacha/chacha_enc.c",
809      "crypto/ct/ct_b64.c",
810      "crypto/ct/ct_err.c",
811      "crypto/ct/ct_log.c",
812      "crypto/ct/ct_oct.c",
813      "crypto/ct/ct_policy.c",
814      "crypto/ct/ct_prn.c",
815      "crypto/ct/ct_sct.c",
816      "crypto/ct/ct_sct_ctx.c",
817      "crypto/ct/ct_vfy.c",
818      "crypto/ct/ct_x509v3.c",
819      "crypto/mem_clr.c",
820      "crypto/rc2/rc2_cbc.c",
821      "crypto/rc2/rc2_ecb.c",
822      "crypto/rc2/rc2_skey.c",
823      "crypto/rc2/rc2cfb64.c",
824      "crypto/rc2/rc2ofb64.c",
825      "crypto/ripemd/rmd_dgst.c",
826      "crypto/ripemd/rmd_one.c",
827      "crypto/sha/keccak1600.c",
828    ]
829    if (is_mingw) {
830      sources -= [
831        "crypto/idea/i_cbc.c",
832        "crypto/idea/i_cfb64.c",
833        "crypto/idea/i_ecb.c",
834        "crypto/idea/i_ofb64.c",
835        "crypto/idea/i_skey.c",
836        "crypto/mdc2/mdc2_one.c",
837        "crypto/mdc2/mdc2dgst.c",
838      ]
839    }
840  } else {
841    sources += [
842      "crypto/aes/aes_core.c",
843      "crypto/chacha/chacha_enc.c",
844      "crypto/mem_clr.c",
845      "crypto/sha/keccak1600.c",
846    ]
847  }
848
849  configs = [ ":crypto_config" ]
850
851  public_configs = [ ":crypto_config_public" ]
852
853  remove_configs = [ "//build/config/coverage:default_coverage" ]
854}
855
856ohos_static_library("libcrypto_static") {
857  deps = [ ":crypto_source" ]
858  public_configs = [ ":crypto_config_public" ]
859  complete_static_lib = true
860  remove_configs = [ "//build/config/coverage:default_coverage" ]
861}
862
863config("ssl_config") {
864  include_dirs = [
865    "./",
866    "./crypto/include",
867    "./include",
868    "./crypto/modes",
869  ]
870  cflags = [
871    "-DNDEBUG",
872    "-DOPENSSL_NO_STATIC_ENGINE",
873    "-DOPENSSL_PIC",
874    "-Wall",
875    "-pthread",
876    "-fPIC",
877    "-DOPENSSL_USE_NODELETE",
878    "-DOPENSSLDIR=\"\"",
879    "-DENGINESDIR=\"\"",
880    "-DOPENSSL_NO_BF",
881    "-DOPENSSL_NO_CAMELLIA",
882    "-DOPENSSL_NO_CAST",
883    "-DOPENSSL_NO_CT",
884    "-DOPENSSL_NO_MD2",
885    "-DOPENSSL_NO_RC5",
886    "-DOPENSSL_NO_RC2",
887    "-DOPENSSL_NO_RIPEMD",
888    "-DOPENSSL_NO_RMD160",
889    "-DOPENSSL_NO_SSL2",
890    "-DOPENSSL_NO_SSL3",
891    "-DOPENSSL_NO_SSL3_METHOD",
892  ]
893
894  if (current_cpu == "arm" && host_os != "mac") {
895    cflags += [ "-DOPENSSL_ARM_PLATFORM" ]
896  } else if (current_cpu == "arm64" &&
897             !(current_os == "linux" || host_os == "mac")) {
898    cflags += [ "-DOPENSSL_ARM64_PLATFORM" ]
899  } else if (is_mingw) {
900    cflags -= [ "-fPIC" ]
901    cflags += [
902      "-m64",
903      "-DL_ENDIAN",
904      "-DUNICODE",
905      "-D_UNICODE",
906      "-DWIN32_LEAN_AND_MEAN",
907      "-D_MT",
908      "-MMD",
909      "-MF",
910      "-c",
911    ]
912    defines = [ "WINDOWS_PLATFORM" ]
913  } else if (host_os == "mac") {
914    cflags += [
915      "-O3",
916      "-DL_ENDIAN",
917      "-D_REENTRAN",
918      "-MMD",
919      "-MF",
920      "-c",
921    ]
922    defines = [ "MAC_PLATFORM" ]
923  } else {
924    cflags += [ "-DOPENSSL_ARM64_PLATFORM" ]
925  }
926}
927
928config("ssl_config_public") {
929  include_dirs = [ "//third_party/openssl/include" ]
930}
931
932ohos_source_set("ssl_source") {
933  sources = [
934    "ssl/bio_ssl.c",
935    "ssl/d1_lib.c",
936    "ssl/d1_msg.c",
937    "ssl/d1_srtp.c",
938    "ssl/methods.c",
939    "ssl/packet.c",
940    "ssl/pqueue.c",
941    "ssl/record/dtls1_bitmap.c",
942    "ssl/record/rec_layer_d1.c",
943    "ssl/record/rec_layer_s3.c",
944    "ssl/record/ssl3_buffer.c",
945    "ssl/record/ssl3_record.c",
946    "ssl/record/ssl3_record_tls13.c",
947    "ssl/s3_cbc.c",
948    "ssl/s3_enc.c",
949    "ssl/s3_lib.c",
950    "ssl/s3_msg.c",
951    "ssl/ssl_asn1.c",
952    "ssl/ssl_cert.c",
953    "ssl/ssl_ciph.c",
954    "ssl/ssl_conf.c",
955    "ssl/ssl_err.c",
956    "ssl/ssl_init.c",
957    "ssl/ssl_lib.c",
958    "ssl/ssl_mcnf.c",
959    "ssl/ssl_rsa.c",
960    "ssl/ssl_sess.c",
961    "ssl/ssl_stat.c",
962    "ssl/ssl_txt.c",
963    "ssl/ssl_utst.c",
964    "ssl/statem/extensions.c",
965    "ssl/statem/extensions_clnt.c",
966    "ssl/statem/extensions_cust.c",
967    "ssl/statem/extensions_srvr.c",
968    "ssl/statem/statem.c",
969    "ssl/statem/statem_clnt.c",
970    "ssl/statem/statem_dtls.c",
971    "ssl/statem/statem_lib.c",
972    "ssl/statem/statem_srvr.c",
973    "ssl/t1_enc.c",
974    "ssl/t1_lib.c",
975    "ssl/t1_trce.c",
976    "ssl/tls13_enc.c",
977    "ssl/tls_srp.c",
978  ]
979
980  public_configs = [ ":ssl_config" ]
981
982  remove_configs = [ "//build/config/coverage:default_coverage" ]
983}
984