blob: 73aff63d5a1d099289c5028d971bc5d56da7183d [file] [log] [blame]
# Copyright 2021 The Pigweed Authors
#
# 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
#
# https://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("//build_overrides/pigweed.gni")
import("$dir_pw_bloat/bloat.gni")
import("$dir_pw_build/facade.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_unit_test/test.gni")
declare_args() {
pw_crypto_SHA256_BACKEND = ""
pw_crypto_ECDSA_BACKEND = ""
}
config("default_config") {
include_dirs = [ "public" ]
visibility = [ ":*" ]
}
config("backend_config") {
include_dirs = [ "public_overrides" ]
visibility = [ ":*" ]
}
pw_facade("sha256") {
backend = pw_crypto_SHA256_BACKEND
public_configs = [ ":default_config" ]
public = [ "public/pw_crypto/sha256.h" ]
public_deps = [
"$dir_pw_bytes",
"$dir_pw_status",
]
deps = [ "$dir_pw_assert" ]
}
pw_doc_group("docs") {
sources = [ "docs.rst" ]
report_deps = [ ":size_report" ]
}
pw_size_report("size_report") {
title = "pw::crypto Size Report"
base = "$dir_pw_bloat:bloat_base"
binaries = []
if (pw_crypto_SHA256_BACKEND != "") {
binaries += [
{
target = "size_report:sha256_simple"
label = "SHA256 ($pw_crypto_SHA256_BACKEND)"
},
]
}
if (pw_crypto_ECDSA_BACKEND != "") {
binaries += [
{
target = "size_report:ecdsa_p256_verify"
label = "ECDSA P256 Verify ($pw_crypto_ECDSA_BACKEND)"
},
]
}
if (binaries == []) {
binaries += [
{
target = "$dir_pw_bloat:bloat_base"
label = "No backend is selected."
},
]
}
}
pw_test_group("tests") {
tests = [
":sha256_test",
":ecdsa_test",
]
}
pw_test("sha256_test") {
enable_if = pw_crypto_SHA256_BACKEND != ""
deps = [ ":sha256" ]
sources = [ "sha256_test.cc" ]
}
pw_source_set("sha256_mbedtls") {
public_configs = [ ":backend_config" ]
public = [
"public/pw_crypto/sha256_mbedtls.h",
"public_overrides/pw_crypto/sha256_backend.h",
]
sources = [ "sha256_mbedtls.cc" ]
public_deps = [
":sha256.facade",
"//third_party/mbedtls",
]
}
pw_facade("ecdsa") {
backend = pw_crypto_ECDSA_BACKEND
public_configs = [ ":default_config" ]
public = [ "public/pw_crypto/ecdsa.h" ]
public_deps = [
"$dir_pw_bytes",
"$dir_pw_status",
]
}
pw_source_set("ecdsa_mbedtls") {
sources = [ "ecdsa_mbedtls.cc" ]
deps = [
"$dir_pw_function",
"$dir_pw_log",
"//third_party/mbedtls",
]
public_deps = [ ":ecdsa.facade" ]
}
pw_test("ecdsa_test") {
enable_if = pw_crypto_ECDSA_BACKEND != ""
deps = [ ":ecdsa" ]
sources = [ "ecdsa_test.cc" ]
}