# Copyright (C) 2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//base/security/crypto_framework/common/common.gni")
import("//base/security/crypto_framework/frameworks/frameworks.gni")
import("//build/ohos.gni")

ohos_shared_library("ohcrypto") {
  branch_protector_ret = "pac_ret"
  if (os_level == "standard") {
    sanitize = {
      cfi = true
      cfi_cross_dso = true
      debug = false
    }
  }

  cflags = [
    "-DHILOG_ENABLE",
    "-fPIC",
    "-Wall",
  ]

  include_dirs = [
    "../../interfaces/kits/native/include",
    "include",
  ]
  include_dirs += framework_inc_path

  sources = [
    "src/asym_key.c",
    "src/crypto_asym_cipher.c",
    "src/crypto_common.c",
    "src/crypto_kdf.c",
    "src/crypto_key_agreement.c",
    "src/crypto_mac.c",
    "src/crypto_rand.c",
    "src/digest.c",
    "src/native_common.c",
    "src/signature.c",
    "src/sym_cipher.c",
    "src/sym_key.c",
  ]

  deps = [ "${framework_path}:crypto_framework_lib" ]

  external_deps = [
    "bounds_checking_function:libsec_shared",
    "hilog:libhilog",
  ]

  subsystem_name = "security"
  output_extension = "so"
  innerapi_tags = [ "ndk" ]
  part_name = "crypto_framework"
}