Bluetooth: Add debug setting for changing minimum encryption key size
For testing and qualification purposes it is useful to allow changing the minimum encryption key size value that the host stack is going to enforce. This adds a new debugfs setting min_encrypt_key_size to achieve this functionality. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:

committed by
Johan Hedberg

parent
6600c0808e
commit
58a96fc353
@@ -3202,6 +3202,7 @@ struct hci_dev *hci_alloc_dev(void)
|
||||
hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;
|
||||
hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;
|
||||
hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;
|
||||
hdev->min_enc_key_size = HCI_MIN_ENC_KEY_SIZE;
|
||||
|
||||
mutex_init(&hdev->lock);
|
||||
mutex_init(&hdev->req_lock);
|
||||
|
@@ -433,6 +433,35 @@ static int auto_accept_delay_set(void *data, u64 val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int min_encrypt_key_size_set(void *data, u64 val)
|
||||
{
|
||||
struct hci_dev *hdev = data;
|
||||
|
||||
if (val < 1 || val > 16)
|
||||
return -EINVAL;
|
||||
|
||||
hci_dev_lock(hdev);
|
||||
hdev->min_enc_key_size = val;
|
||||
hci_dev_unlock(hdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int min_encrypt_key_size_get(void *data, u64 *val)
|
||||
{
|
||||
struct hci_dev *hdev = data;
|
||||
|
||||
hci_dev_lock(hdev);
|
||||
*val = hdev->min_enc_key_size;
|
||||
hci_dev_unlock(hdev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEFINE_SIMPLE_ATTRIBUTE(min_encrypt_key_size_fops,
|
||||
min_encrypt_key_size_get,
|
||||
min_encrypt_key_size_set, "%llu\n");
|
||||
|
||||
static int auto_accept_delay_get(void *data, u64 *val)
|
||||
{
|
||||
struct hci_dev *hdev = data;
|
||||
@@ -545,6 +574,8 @@ void hci_debugfs_create_bredr(struct hci_dev *hdev)
|
||||
if (lmp_ssp_capable(hdev)) {
|
||||
debugfs_create_file("ssp_debug_mode", 0444, hdev->debugfs,
|
||||
hdev, &ssp_debug_mode_fops);
|
||||
debugfs_create_file("min_encrypt_key_size", 0644, hdev->debugfs,
|
||||
hdev, &min_encrypt_key_size_fops);
|
||||
debugfs_create_file("auto_accept_delay", 0644, hdev->debugfs,
|
||||
hdev, &auto_accept_delay_fops);
|
||||
}
|
||||
|
@@ -1361,7 +1361,7 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon)
|
||||
* actually encrypted before enforcing a key size.
|
||||
*/
|
||||
return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) ||
|
||||
hcon->enc_key_size >= HCI_MIN_ENC_KEY_SIZE);
|
||||
hcon->enc_key_size >= hcon->hdev->min_enc_key_size);
|
||||
}
|
||||
|
||||
static void l2cap_do_start(struct l2cap_chan *chan)
|
||||
|
Reference in New Issue
Block a user