1# Copyright (C) 2022-2023 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("//build/ohos.gni")
17
18ohos_shared_library("cj_cryptoframework_ffi") {
19  branch_protector_ret = "pac_ret"
20  include_dirs = [ "include" ]
21  include_dirs += framework_inc_path
22
23  if (os_level == "standard") {
24    sanitize = {
25      cfi = true
26      cfi_cross_dso = true
27      debug = false
28    }
29  }
30
31  cflags = [
32    "-DHILOG_ENABLE",
33    "-fPIC",
34    "-g3",
35  ]
36
37  if (!defined(defines)) {
38    defines = []
39  }
40
41  if (!ohos_indep_compiler_enable && !build_ohos_sdk &&
42      product_name != "qemu-arm-linux-min" &&
43      product_name != "rk3568_mini_system") {
44    deps = [ "${framework_path}:crypto_framework_lib" ]
45    external_deps = [
46      "bounds_checking_function:libsec_shared",
47      "hilog:libhilog",
48      "napi:ace_napi",
49      "napi:cj_bind_ffi",
50      "napi:cj_bind_native",
51    ]
52    sources = [
53      "src/asy_key_generator_impl.cpp",
54      "src/asy_key_spec_generator_impl.cpp",
55      "src/cipher_impl.cpp",
56      "src/crypto_ffi.cpp",
57      "src/dh_key_util_impl.cpp",
58      "src/ecc_key_util_impl.cpp",
59      "src/kdf_impl.cpp",
60      "src/key_agreement_impl.cpp",
61      "src/key_impl.cpp",
62      "src/key_pair_impl.cpp",
63      "src/mac_impl.cpp",
64      "src/md_impl.cpp",
65      "src/pri_key_impl.cpp",
66      "src/pub_key_impl.cpp",
67      "src/random_impl.cpp",
68      "src/sign_impl.cpp",
69      "src/sm2_crypto_util_impl.cpp",
70      "src/sym_key_generator_impl.cpp",
71      "src/sym_key_impl.cpp",
72      "src/verify_impl.cpp",
73    ]
74  } else {
75    defines += [ "PREVIEWER" ]
76    sources = [ "src/crypto_mock.cpp" ]
77    external_deps = [ "napi:cj_bind_ffi" ]
78  }
79
80  if (is_ohos) {
81    defines += [ "OHOS_PLATFORM" ]
82  }
83
84  if (is_mingw) {
85    defines += [ "WINDOWS_PLATFORM" ]
86  }
87
88  innerapi_tags = [ "platformsdk" ]
89
90  subsystem_name = "security"
91  part_name = "crypto_framework"
92}
93