hci_conn.c (66138ce8e556a8ddd13baf035fb3a8d0d6dd4bb5) hci_conn.c (7b5a9241b780ea2f77e71647bc0d3c9708c18ef1)
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as

--- 786 unchanged lines hidden (view full) ---

795 key. */
796 if (sec_level == BT_SECURITY_LOW && !hci_conn_ssp_enabled(conn))
797 return 1;
798
799 /* For other security levels we need the link key. */
800 if (!(conn->link_mode & HCI_LM_AUTH))
801 goto auth;
802
1/*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (c) 2000-2001, 2010, Code Aurora Forum. All rights reserved.
4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as

--- 786 unchanged lines hidden (view full) ---

795 key. */
796 if (sec_level == BT_SECURITY_LOW && !hci_conn_ssp_enabled(conn))
797 return 1;
798
799 /* For other security levels we need the link key. */
800 if (!(conn->link_mode & HCI_LM_AUTH))
801 goto auth;
802
803 /* An authenticated combination key has sufficient security for any
804 security level. */
805 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P192 ||
806 conn->key_type == HCI_LK_AUTH_COMBINATION_P256)
803 /* An authenticated FIPS approved combination key has sufficient
804 * security for security level 4. */
805 if (conn->key_type == HCI_LK_AUTH_COMBINATION_P256 &&
806 sec_level == BT_SECURITY_FIPS)
807 goto encrypt;
808
807 goto encrypt;
808
809 /* An authenticated combination key has sufficient security for
810 security level 3. */
811 if ((conn->key_type == HCI_LK_AUTH_COMBINATION_P192 ||
812 conn->key_type == HCI_LK_AUTH_COMBINATION_P256) &&
813 sec_level == BT_SECURITY_HIGH)
814 goto encrypt;
815
809 /* An unauthenticated combination key has sufficient security for
810 security level 1 and 2. */
811 if ((conn->key_type == HCI_LK_UNAUTH_COMBINATION_P192 ||
812 conn->key_type == HCI_LK_UNAUTH_COMBINATION_P256) &&
813 (sec_level == BT_SECURITY_MEDIUM || sec_level == BT_SECURITY_LOW))
814 goto encrypt;
815
816 /* A combination key has always sufficient security for the security
817 levels 1 or 2. High security level requires the combination key
818 is generated using maximum PIN code length (16).
819 For pre 2.1 units. */
820 if (conn->key_type == HCI_LK_COMBINATION &&
816 /* An unauthenticated combination key has sufficient security for
817 security level 1 and 2. */
818 if ((conn->key_type == HCI_LK_UNAUTH_COMBINATION_P192 ||
819 conn->key_type == HCI_LK_UNAUTH_COMBINATION_P256) &&
820 (sec_level == BT_SECURITY_MEDIUM || sec_level == BT_SECURITY_LOW))
821 goto encrypt;
822
823 /* A combination key has always sufficient security for the security
824 levels 1 or 2. High security level requires the combination key
825 is generated using maximum PIN code length (16).
826 For pre 2.1 units. */
827 if (conn->key_type == HCI_LK_COMBINATION &&
821 (sec_level != BT_SECURITY_HIGH || conn->pin_length == 16))
828 (sec_level == BT_SECURITY_MEDIUM || sec_level == BT_SECURITY_LOW ||
829 conn->pin_length == 16))
822 goto encrypt;
823
824auth:
825 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
826 return 0;
827
828 if (!hci_conn_auth(conn, sec_level, auth_type))
829 return 0;

--- 298 unchanged lines hidden ---
830 goto encrypt;
831
832auth:
833 if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
834 return 0;
835
836 if (!hci_conn_auth(conn, sec_level, auth_type))
837 return 0;

--- 298 unchanged lines hidden ---