• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
19config("public_include_path") {
20  include_dirs = [ "public" ]
21}
22
23pw_source_set("definitions") {
24  sources = [
25    "error.cc",
26    "packet.cc",
27    "types.cc",
28  ]
29  public = [
30    "public/pw_bluetooth_sapphire/internal/host/sm/delegate.h",
31    "public/pw_bluetooth_sapphire/internal/host/sm/error.h",
32    "public/pw_bluetooth_sapphire/internal/host/sm/packet.h",
33    "public/pw_bluetooth_sapphire/internal/host/sm/smp.h",
34    "public/pw_bluetooth_sapphire/internal/host/sm/types.h",
35  ]
36  public_configs = [ ":public_include_path" ]
37  public_deps = [
38    "$dir_pw_bluetooth_sapphire/host/common",
39    "$dir_pw_bluetooth_sapphire/host/hci-spec",  # hci_spec::LinkKey
40    "$dir_pw_chrono:system_clock",
41    "$dir_pw_third_party/fuchsia:fit",
42  ]
43  deps = [
44    "$dir_pw_bluetooth_sapphire/lib/cpp-string",
45    dir_pw_preprocessor,
46    dir_pw_string,
47  ]
48}
49
50pw_source_set("sm") {
51  sources = [
52    "ecdh_key.cc",
53    "pairing_channel.cc",
54    "pairing_phase.cc",
55    "phase_1.cc",
56    "phase_2_legacy.cc",
57    "phase_2_secure_connections.cc",
58    "phase_3.cc",
59    "sc_stage_1_just_works_numeric_comparison.cc",
60    "sc_stage_1_passkey.cc",
61    "security_manager.cc",
62    "security_request_phase.cc",
63    "util.cc",
64  ]
65  public = [
66    "public/pw_bluetooth_sapphire/internal/host/sm/ecdh_key.h",
67    "public/pw_bluetooth_sapphire/internal/host/sm/pairing_channel.h",
68    "public/pw_bluetooth_sapphire/internal/host/sm/pairing_phase.h",
69    "public/pw_bluetooth_sapphire/internal/host/sm/phase_1.h",
70    "public/pw_bluetooth_sapphire/internal/host/sm/phase_2_legacy.h",
71    "public/pw_bluetooth_sapphire/internal/host/sm/phase_2_secure_connections.h",
72    "public/pw_bluetooth_sapphire/internal/host/sm/phase_3.h",
73    "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1.h",
74    "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1_just_works_numeric_comparison.h",
75    "public/pw_bluetooth_sapphire/internal/host/sm/sc_stage_1_passkey.h",
76    "public/pw_bluetooth_sapphire/internal/host/sm/security_manager.h",
77    "public/pw_bluetooth_sapphire/internal/host/sm/security_request_phase.h",
78    "public/pw_bluetooth_sapphire/internal/host/sm/util.h",
79  ]
80  public_configs = [ ":public_include_path" ]
81  public_deps = [
82    ":definitions",
83    "$dir_pw_bluetooth_sapphire:config",
84    "$dir_pw_bluetooth_sapphire/host/gap:definitions",
85    "$dir_pw_bluetooth_sapphire/host/gap:peer",
86    "$dir_pw_bluetooth_sapphire/host/hci",
87    "$dir_pw_bluetooth_sapphire/host/l2cap",
88    "$dir_pw_crypto:aes",
89    "$dir_pw_crypto:aes_cmac",
90    "$dir_pw_third_party/boringssl",
91    "$dir_pw_third_party/fuchsia:fit",
92    dir_pw_string,
93  ]
94}
95
96pw_source_set("testing") {
97  sources = [ "test_security_manager.cc" ]
98  public = [
99    "public/pw_bluetooth_sapphire/internal/host/sm/fake_phase_listener.h",
100    "public/pw_bluetooth_sapphire/internal/host/sm/test_security_manager.h",
101  ]
102  public_configs = [ ":public_include_path" ]
103  deps = [
104    ":definitions",
105    ":sm",
106    "$dir_pw_bluetooth_sapphire/host/common",
107    "$dir_pw_bluetooth_sapphire/host/gap:definitions",
108    "$dir_pw_bluetooth_sapphire/host/hci",
109    "$dir_pw_bluetooth_sapphire/host/hci-spec",
110    "$dir_pw_bluetooth_sapphire/host/l2cap",
111  ]
112}
113
114pw_test("sm_tests") {
115  enable_if = pw_unit_test_BACKEND == "$dir_pw_unit_test:googletest"
116  sources = [
117    "ecdh_key_test.cc",
118    "error_test.cc",
119    "packet_test.cc",
120    "pairing_channel_test.cc",
121    "pairing_phase_test.cc",
122    "phase_1_test.cc",
123    "phase_2_legacy_test.cc",
124    "phase_2_secure_connections_test.cc",
125    "phase_3_test.cc",
126    "sc_stage_1_just_works_numeric_comparison_test.cc",
127    "sc_stage_1_passkey_test.cc",
128    "security_manager_test.cc",
129    "security_request_phase_test.cc",
130    "types_test.cc",
131    "util_test.cc",
132  ]
133  test_main = "$dir_pw_bluetooth_sapphire/host/testing:gtest_main"
134  deps = [
135    ":sm",
136    ":testing",
137    "$dir_pw_bluetooth_sapphire/host/hci:testing",
138    "$dir_pw_bluetooth_sapphire/host/l2cap:testing",
139    "$dir_pw_bluetooth_sapphire/host/testing",
140    "$dir_pw_bluetooth_sapphire/host/testing:mock_controller",
141    "$dir_pw_bluetooth_sapphire/host/testing:test_helpers",
142  ]
143}
144
145pw_fuzzer("valid_packet_reader_fuzzer") {
146  sources = [ "valid_packet_reader_parse_sdu_fuzztest.cc" ]
147  deps = [ ":definitions" ]
148}
149
150pw_test_group("tests") {
151  tests = [
152    ":sm_tests",
153    ":valid_packet_reader_fuzzer_test",
154  ]
155}
156