@@ -56,6 +56,8 @@ ble_error_t GenericSecurityManager::init(
56
56
_default_authentication.set_secure_connections (secure_connections);
57
57
_default_authentication.set_keypress_notification (true );
58
58
59
+ _default_key_distribution.set_link (secure_connections);
60
+
59
61
_default_key_distribution.set_signing (signing);
60
62
if (signing) {
61
63
init_signing ();
@@ -126,7 +128,7 @@ ble_error_t GenericSecurityManager::requestPairing(connection_handle_t connectio
126
128
127
129
/* by default the initiator doesn't send any keys other then identity */
128
130
KeyDistribution initiator_distribution (
129
- KeyDistribution::KEY_DISTRIBUTION_IDENTITY | KeyDistribution::KEY_DISTRIBUTION_LINK
131
+ KeyDistribution::KEY_DISTRIBUTION_IDENTITY | _default_key_distribution. get_link ()
130
132
);
131
133
132
134
/* if requested the initiator may send all the default keys for later
@@ -171,28 +173,28 @@ ble_error_t GenericSecurityManager::acceptPairingRequest(connection_handle_t con
171
173
link_authentication.set_mitm (true );
172
174
}
173
175
174
- KeyDistribution initiator_dist = cb->get_initiator_key_distribution ();
176
+ KeyDistribution initiator_distribution = cb->get_initiator_key_distribution ();
175
177
176
178
if (_master_sends_keys) {
177
- initiator_dist &= _default_key_distribution;
179
+ initiator_distribution &= _default_key_distribution;
178
180
} else {
179
- initiator_dist &= KeyDistribution (KeyDistribution::KEY_DISTRIBUTION_IDENTITY | KeyDistribution::KEY_DISTRIBUTION_LINK);
181
+ initiator_distribution &= KeyDistribution (KeyDistribution::KEY_DISTRIBUTION_IDENTITY | KeyDistribution::KEY_DISTRIBUTION_LINK);
180
182
}
181
183
182
184
/* signing has to be offered and enabled on the link */
183
- if (initiator_dist .get_signing ()) {
184
- initiator_dist .set_signing (
185
+ if (initiator_distribution .get_signing ()) {
186
+ initiator_distribution .set_signing (
185
187
cb->signing_override_default ? cb->signing_requested : _default_key_distribution.get_signing ()
186
188
);
187
189
}
188
190
189
- KeyDistribution responder_dist (cb->get_responder_key_distribution ());
191
+ KeyDistribution responder_distribution (cb->get_responder_key_distribution ());
190
192
191
- responder_dist &= _default_key_distribution;
193
+ responder_distribution &= _default_key_distribution;
192
194
193
195
/* signing has to be requested and enabled on the link */
194
- if (responder_dist .get_signing ()) {
195
- responder_dist .set_signing (
196
+ if (responder_distribution .get_signing ()) {
197
+ responder_distribution .set_signing (
196
198
cb->signing_override_default ? cb->signing_requested : _default_key_distribution.get_signing ()
197
199
);
198
200
}
@@ -201,8 +203,8 @@ ble_error_t GenericSecurityManager::acceptPairingRequest(connection_handle_t con
201
203
connection,
202
204
cb->oob_present ,
203
205
link_authentication,
204
- responder_dist ,
205
- responder_dist
206
+ initiator_distribution ,
207
+ responder_distribution
206
208
);
207
209
}
208
210
0 commit comments