1# Copyright 2023 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 15import("//build_overrides/pigweed.gni") 16import("$dir_pw_fuzzer/fuzzer.gni") 17import("$dir_pw_unit_test/test.gni") 18 19dir_public_sm = "../../public/pw_bluetooth_sapphire/internal/host/sm" 20 21pw_source_set("definitions") { 22 public = [ 23 "$dir_public_sm/error.h", 24 "$dir_public_sm/packet.h", 25 "$dir_public_sm/smp.h", 26 "$dir_public_sm/types.h", 27 ] 28 29 sources = [ 30 "error.cc", 31 "packet.cc", 32 "types.cc", 33 ] 34 35 public_deps = [ 36 "$dir_pw_bluetooth_sapphire/host/common", 37 "$dir_pw_bluetooth_sapphire/host/hci-spec", # hci_spec::LinkKey 38 ] 39 40 deps = [ "$dir_pw_preprocessor" ] 41} 42 43pw_source_set("sm") { 44 public = [ 45 "$dir_public_sm/ecdh_key.h", 46 "$dir_public_sm/pairing_channel.h", 47 "$dir_public_sm/pairing_phase.h", 48 "$dir_public_sm/phase_1.h", 49 "$dir_public_sm/phase_2_legacy.h", 50 "$dir_public_sm/phase_2_secure_connections.h", 51 "$dir_public_sm/phase_3.h", 52 "$dir_public_sm/sc_stage_1.h", 53 "$dir_public_sm/sc_stage_1_just_works_numeric_comparison.h", 54 "$dir_public_sm/sc_stage_1_passkey.h", 55 "$dir_public_sm/security_manager.h", 56 "$dir_public_sm/security_request_phase.h", 57 "$dir_public_sm/util.h", 58 ] 59 60 sources = [ 61 "ecdh_key.cc", 62 "pairing_channel.cc", 63 "pairing_phase.cc", 64 "phase_1.cc", 65 "phase_2_legacy.cc", 66 "phase_2_secure_connections.cc", 67 "phase_3.cc", 68 "sc_stage_1_just_works_numeric_comparison.cc", 69 "sc_stage_1_passkey.cc", 70 "security_manager.cc", 71 "security_request_phase.cc", 72 "util.cc", 73 ] 74 75 public_deps = [ 76 ":definitions", 77 "$dir_pw_bluetooth_sapphire:config", 78 "$dir_pw_bluetooth_sapphire/host/gap:definitions", 79 "$dir_pw_bluetooth_sapphire/host/hci", 80 "$dir_pw_bluetooth_sapphire/host/l2cap", 81 "$dir_pw_string", 82 "$dir_pw_third_party/boringssl", 83 "$dir_pw_third_party/fuchsia:fit", 84 ] 85} 86 87pw_source_set("testing") { 88 public = [ 89 "$dir_public_sm/fake_phase_listener.h", 90 "$dir_public_sm/test_security_manager.h", 91 ] 92 93 sources = [ "test_security_manager.cc" ] 94 95 deps = [ ":sm" ] 96} 97 98pw_test("sm_tests") { 99 sources = [ 100 "ecdh_key_test.cc", 101 "error_test.cc", 102 "packet_test.cc", 103 "pairing_channel_test.cc", 104 "pairing_phase_test.cc", 105 "phase_1_test.cc", 106 "phase_2_legacy_test.cc", 107 "phase_2_secure_connections_test.cc", 108 "phase_3_test.cc", 109 "sc_stage_1_just_works_numeric_comparison_test.cc", 110 "sc_stage_1_passkey_test.cc", 111 "security_manager_test.cc", 112 "security_request_phase_test.cc", 113 "types_test.cc", 114 "util_test.cc", 115 ] 116 117 deps = [ 118 ":sm", 119 ":testing", 120 "$dir_pw_bluetooth_sapphire/host/hci:testing", 121 "$dir_pw_bluetooth_sapphire/host/l2cap:testing", 122 "$dir_pw_bluetooth_sapphire/host/testing", 123 ] 124 125 test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main" 126} 127 128pw_fuzzer("valid_packet_reader_fuzzer") { 129 sources = [ "valid_packet_reader_parse_sdu_fuzztest.cc" ] 130 deps = [ ":definitions" ] 131} 132 133pw_test_group("tests") { 134 tests = [ 135 ":sm_tests", 136 ":valid_packet_reader_fuzzer_test", 137 ] 138} 139