1# Copyright 2024 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@rules_cc//cc:cc_library.bzl", "cc_library") 16load("//pw_fuzzer:fuzzer.bzl", "pw_cc_fuzz_test") 17load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 18 19package( 20 default_visibility = ["//visibility:public"], 21 features = ["-layering_check"], 22) 23 24cc_library( 25 name = "definitions", 26 srcs = [ 27 "error.cc", 28 "packet.cc", 29 "types.cc", 30 ], 31 hdrs = [ 32 "public/pw_bluetooth_sapphire/internal/host/sm/error.h", 33 "public/pw_bluetooth_sapphire/internal/host/sm/packet.h", 34 "public/pw_bluetooth_sapphire/internal/host/sm/smp.h", 35 "public/pw_bluetooth_sapphire/internal/host/sm/types.h", 36 ], 37 implementation_deps = [ 38 "//pw_bluetooth_sapphire/lib/cpp-string", 39 "//pw_preprocessor", 40 "//pw_string", 41 ], 42 strip_include_prefix = "public", 43 tags = ["noclangtidy"], 44 deps = [ 45 "//pw_bluetooth_sapphire/host/common", 46 "//pw_bluetooth_sapphire/host/hci-spec", 47 "//pw_chrono:system_clock", 48 "//third_party/fuchsia:fit", 49 ], 50) 51 52cc_library( 53 name = "sm", 54 srcs = [ 55 "ecdh_key.cc", 56 "pairing_channel.cc", 57 "pairing_phase.cc", 58 "phase_1.cc", 59 "phase_2_legacy.cc", 60 "phase_2_secure_connections.cc", 61 "phase_3.cc", 62 "sc_stage_1_just_works_numeric_comparison.cc", 63 "sc_stage_1_passkey.cc", 64 "security_manager.cc", 65 "security_request_phase.cc", 66 "util.cc", 67 ], 68 hdrs = [ 69 "public/pw_bluetooth_sapphire/internal/host/sm/delegate.h", 70 "public/pw_bluetooth_sapphire/internal/host/sm/ecdh_key.h", 71 "public/pw_bluetooth_sapphire/internal/host/sm/pairing_channel.h", 72 "public/pw_bluetooth_sapphire/internal/host/sm/pairing_phase.h", 73 "public/pw_bluetooth_sapphire/internal/host/sm/phase_1.h", 74 "public/pw_bluetooth_sapphire/internal/host/sm/phase_2_legacy.h", 75 "public/pw_bluetooth_sapphire/internal/host/sm/phase_2_secure_connections.h", 76 "public/pw_bluetooth_sapphire/internal/host/sm/phase_3.h", 77 "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1.h", 78 "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1_just_works_numeric_comparison.h", 79 "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1_passkey.h", 80 "public/pw_bluetooth_sapphire/internal/host/sm/security_manager.h", 81 "public/pw_bluetooth_sapphire/internal/host/sm/security_request_phase.h", 82 "public/pw_bluetooth_sapphire/internal/host/sm/util.h", 83 ], 84 strip_include_prefix = "public", 85 tags = ["noclangtidy"], 86 deps = [ 87 ":definitions", 88 "//pw_bluetooth_sapphire/host/common", 89 "//pw_bluetooth_sapphire/host/gap:definitions", 90 "//pw_bluetooth_sapphire/host/gap:peer", 91 "//pw_bluetooth_sapphire/host/hci", 92 "//pw_bluetooth_sapphire/host/l2cap", 93 "//pw_bluetooth_sapphire/lib/cpp-string", 94 "//pw_crypto:aes", 95 "//pw_crypto:aes_cmac", 96 "//third_party/fuchsia:fit", 97 "@boringssl//:crypto", 98 ], 99) 100 101cc_library( 102 name = "testing", 103 srcs = [ 104 "test_security_manager.cc", 105 ], 106 hdrs = [ 107 "public/pw_bluetooth_sapphire/internal/host/sm/fake_phase_listener.h", 108 "public/pw_bluetooth_sapphire/internal/host/sm/test_security_manager.h", 109 ], 110 strip_include_prefix = "public", 111 tags = ["noclangtidy"], 112 deps = [ 113 ":definitions", 114 ":sm", 115 "//pw_bluetooth_sapphire/host/common", 116 "//pw_bluetooth_sapphire/host/gap:definitions", 117 "//pw_bluetooth_sapphire/host/hci", 118 "//pw_bluetooth_sapphire/host/hci-spec", 119 "//pw_bluetooth_sapphire/host/l2cap", 120 ], 121) 122 123pw_cc_test( 124 name = "sm_test", 125 srcs = [ 126 "ecdh_key_test.cc", 127 "error_test.cc", 128 "packet_test.cc", 129 "pairing_channel_test.cc", 130 "pairing_phase_test.cc", 131 "phase_1_test.cc", 132 "phase_2_legacy_test.cc", 133 "phase_2_secure_connections_test.cc", 134 "phase_3_test.cc", 135 "sc_stage_1_just_works_numeric_comparison_test.cc", 136 "sc_stage_1_passkey_test.cc", 137 "security_manager_test.cc", 138 "security_request_phase_test.cc", 139 "types_test.cc", 140 "util_test.cc", 141 ], 142 # TODO: https://pwbug.dev/393957973 - Fix this test. 143 tags = ["noubsan"], 144 test_main = "//pw_bluetooth_sapphire/host/testing:gtest_main", 145 deps = [ 146 ":sm", 147 ":testing", 148 "//pw_bluetooth_sapphire/host/hci:testing", 149 "//pw_bluetooth_sapphire/host/l2cap:testing", 150 "//pw_bluetooth_sapphire/host/testing", 151 "//pw_bluetooth_sapphire/host/testing:mock_controller", 152 "//pw_bluetooth_sapphire/host/testing:test_helpers", 153 ], 154) 155 156pw_cc_fuzz_test( 157 name = "valid_packet_reader_fuzzer", 158 srcs = ["valid_packet_reader_parse_sdu_fuzztest.cc"], 159 deps = [":definitions"], 160) 161