Commit 8f360119 authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by Gustavo F. Padovan
Browse files

Bluetooth: Add support for returning the encryption key size

This will be useful when userspace wants to restrict some kinds of
operations based on the length of the key size used to encrypt the
Signed-off-by: default avatarVinicius Costa Gomes <>
Signed-off-by: default avatarGustavo F. Padovan <>
parent 726b4ffc
......@@ -56,6 +56,7 @@
#define BT_SECURITY 4
struct bt_security {
__u8 level;
__u8 key_size;
......@@ -422,8 +422,12 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
memset(&sec, 0, sizeof(sec));
sec.level = chan->sec_level;
if (sk->sk_state == BT_CONNECTED)
sec.key_size = chan->conn->hcon->enc_key_size;
len = min_t(unsigned int, len, sizeof(sec));
if (copy_to_user(optval, (char *) &sec, len))
err = -EFAULT;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment