@@ -119,7 +119,10 @@ ble_error_t GenericSecurityManager::requestPairing(connection_handle_t connectio
119
119
update_oob_presence (connection);
120
120
121
121
AuthenticationMask link_authentication (_default_authentication);
122
- link_authentication.set_mitm (cb->mitm_requested );
122
+
123
+ if (cb->mitm_requested ) {
124
+ link_authentication.set_mitm (true );
125
+ }
123
126
124
127
/* by default the initiator doesn't send any keys other then identity */
125
128
KeyDistribution initiator_distribution (
@@ -133,9 +136,12 @@ ble_error_t GenericSecurityManager::requestPairing(connection_handle_t connectio
133
136
}
134
137
135
138
/* override default if requested */
136
- initiator_distribution.set_signing (
137
- cb->signing_override_default ? cb->signing_requested : _default_key_distribution.get_signing ()
138
- );
139
+ if (cb->signing_override_default ) {
140
+ initiator_distribution.set_signing (cb->signing_requested );
141
+ } else {
142
+ /* because _master_sends_keys might be false so we need to set this */
143
+ initiator_distribution.set_signing (_default_key_distribution.get_signing ());
144
+ }
139
145
140
146
KeyDistribution responder_distribution (_default_key_distribution);
141
147
@@ -161,7 +167,9 @@ ble_error_t GenericSecurityManager::acceptPairingRequest(connection_handle_t con
161
167
update_oob_presence (connection);
162
168
163
169
AuthenticationMask link_authentication (_default_authentication);
164
- link_authentication.set_mitm (cb->mitm_requested );
170
+ if (cb->mitm_requested ) {
171
+ link_authentication.set_mitm (true );
172
+ }
165
173
166
174
KeyDistribution initiator_dist = cb->get_initiator_key_distribution ();
167
175
@@ -172,20 +180,22 @@ ble_error_t GenericSecurityManager::acceptPairingRequest(connection_handle_t con
172
180
}
173
181
174
182
/* signing has to be offered and enabled on the link */
175
- initiator_dist.set_signing (
176
- initiator_dist.get_signing ()
177
- && (
178
- cb-> signing_override_default ? cb-> signing_requested : _default_key_distribution. get_signing ())
179
- );
183
+ if ( initiator_dist.get_signing ()) {
184
+ initiator_dist.set_signing (
185
+ cb-> signing_override_default ? cb-> signing_requested : _default_key_distribution. get_signing ()
186
+ );
187
+ }
180
188
181
- KeyDistribution responder_dist = cb->get_responder_key_distribution ();
189
+ KeyDistribution responder_dist ( cb->get_responder_key_distribution () );
182
190
183
191
responder_dist &= _default_key_distribution;
192
+
184
193
/* signing has to be requested and enabled on the link */
185
- responder_dist.set_signing (
186
- responder_dist.get_signing ()
187
- && (cb->signing_override_default ? cb->signing_requested : _default_key_distribution.get_signing ())
188
- );
194
+ if (responder_dist.get_signing ()) {
195
+ responder_dist.set_signing (
196
+ cb->signing_override_default ? cb->signing_requested : _default_key_distribution.get_signing ()
197
+ );
198
+ }
189
199
190
200
return _pal.send_pairing_response (
191
201
connection,
0 commit comments