Commit graph

370 commits

Author SHA1 Message Date
Johan Hedberg
03ea90db8f Bluetooth: Rework local address tracking
Store the Identity Address and Random Address in their own variables.
If the controller doesn't have a public address a static random
address is set as the Identity Address. Also keep properly track of
which address was used for advertising and initiating connections so
that the connection object contains the right information.

Change-Id: I3e9dc2036b330c19c2725b180fd061da2df8a0fa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-04 13:56:55 +03:00
Johan Hedberg
9eec87a0ef Bluetooth: Remove unnecessary double check for CONFIG_BLUETOOTH_CONN
Change-Id: I3329cf1314cbcd4e6bb7015b9b52fd6c52526567
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-02 20:59:09 +03:00
Johan Hedberg
a85b1f7752 Bluetooth: Shorten set_adv_parameters to set_adv_param
The shorter form "param" is used elsewhere and this helps avoid overly
long lines.

Change-Id: Ie76497b5bf30e72099d13a26db9cacb8cd2c9c79
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-02 20:59:09 +03:00
Johan Hedberg
74dbbcac61 Bluetooth: Make controller to host flow control conditional
Deal with controllers that don't support controller to host control.
This may potentially lead to dropped packets so make a clear warning
log of the issue.

Change-Id: Ie8fdaed826a072fd157343721222f618328d59a3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-01 08:41:39 +03:00
Johan Hedberg
4763bb9c86 Bluetooth: Move supported commands reading to common_init()
Reading supported commands isn't an LE-specific feature, so the
command should be in common_init() rather than le_init().

Change-Id: I613bbe8d39b4c2b6dadc45a710bc59568ec9b488
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-04-01 08:37:18 +03:00
Szymon Janc
e23e4c76e2 Bluetooth: Add support for resolving BR/EDR names
If BR/EDR device didn't provide name in EIR (or no EIR at all) names
are resolved after discovery is completed. Resolved names are put into
EIR block.

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x280424
          Major class: Audio/Video (headset, speaker, stereo, video, vcr)
          Minor class: Set-top box
          Capturing (Scanner, Microphone)
          Audio (Speaker, Microphone, Headset)
        Clock offset: 0x47d5
        RSSI: -88 dBm (0xa8)
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page scan mode: Mandatory (0x00)
        Clock offset: 0x47d5
> HCI Event: Command Status (0x0f) plen 4
      Remote Name Request (0x01|0x0019) ncmd 1
        Status: Success (0x00)
> HCI Event: Remote Name Req Complete (0x07) plen 255
        Status: Success (0x00)
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Name: Nexus Player

Change-Id: Ica5f6cc8a7d9dc7a925025bc62faab2caec47dbb
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-26 05:57:34 +00:00
Szymon Janc
067d5cfb63 Bluetooth: Add support for notifying of BR/EDR inquiry results
This allows to notify application of inquiry results.

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: C4:43:8F:A3:4D:83 (LG Electronics)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x5a020c
        ...
        Clock offset: 0x73e8
        RSSI: -66 dBm (0xbe)
        Name (complete): Nexus 5

> HCI Event: Extended Inquiry Result (0x2f) plen 255
        Num responses: 1
        Address: F0:79:59:03:6B:30 (ASUSTek COMPUTER INC.)
        Page scan repetition mode: R1 (0x01)
        Page period mode: P0 (0x00)
        Class: 0x280424
        ....
        Clock offset: 0x47d5
        RSSI: -88 dBm (0xa8)

Change-Id: I36215a7139ae49c50ef71a8b647204bf5063cd13
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-25 19:28:24 +00:00
Szymon Janc
ca662c14f1 Bluetooth: Add initial support for BR/EDR discovery
This allows to start (general or limited) BR/EDR discovery. Inquiry
is active until explicitly disabled by application. This is to keep
BR/EDR discovery API similar to LE scan API.

< HCI Command: Inquiry (0x01|0x0001) plen 5
        Access code: 0x9e8b33 (General Inquiry)
        Length: 61.44s (0x30)
        Num responses: 0
> HCI Event: Command Status (0x0f) plen 4
      Inquiry (0x01|0x0001) ncmd 1
        Status: Success (0x00)
> HCI Event: Inquiry Complete (0x01) plen 1
        Status: Success (0x00)

Change-Id: I946fbd881e6d0460be28a9975acd564ae32896e8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-03-24 20:25:02 +00:00
Arkadiusz Lichwa
5cecd07ba2 Bluetooth: BR/EDR: Refactor link key notify handler
Makes proper link key handling based on its type.

Change-Id: I052cc4629e531ea9ae7da95a7268778e633bdba5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-24 08:32:28 +00:00
Arkadiusz Lichwa
dc6085667e Bluetooth: BR/EDR: Fix storing legacy link key
Stores in keys database legacy (Pre-SSP) link key.

Change-Id: I848e0e29e22edacb24c1a26ffed7a68dff08fed8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-23 11:54:29 +00:00
Mariusz Skamra
3d35533c95 Bluetooth: Fix validation of advertising parameters
According to the Core Sepcification, Advertising Interval Min/Max
shall not be set to less than 0x00a0 if ADV_SCAN_IND or ADV_NONCONN_IND
type is used.

Change-Id: Ib10f7ec8cdf92dd67e602a9b57d20a35ebacde4e
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-03-22 15:16:12 +00:00
Arkadiusz Lichwa
158cdbf91a Bluetooth: Fix checkpatch error/warnings
Fixes some checkpatch's errors/warning in HCI stack code.

Change-Id: I105fb491b5509f72549ab788764b1386ce3af47f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 14:48:40 +01:00
Arkadiusz Lichwa
b0bc48370d Bluetooth: BR/EDR: Add no-bond keys flag
When bond is required only for current connection session, don't store
the link key value in keys database when such link key is generated.
Release the link key storage on disconnection complete.

> HCI Event: IO Capability Response (0x32) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: DisplayOnly (0x00)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: IO Capability Request (0x31) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: KeyboardOnly (0x02)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: Command Complete (0x0e) plen 10

Change-Id: Ibd29457a9183f33f28264b857dd2de01f96d266f
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:13:12 +00:00
Arkadiusz Lichwa
6f30525278 Bluetooth: BR/EDR: Handle User Passkey Entry event
Enables handle request from remote to enter passkey by the user to
continue SSP authentication process. It happens when local device
supports 'keyboard only' functionality. Otherwise the response is
negative.

> HCI Event: IO Capability Response (0x32) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: DisplayOnly (0x00)
	OOB data: Authentication data not present (0x00)
	Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: IO Capability Request (0x31) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: KeyboardOnly (0x02)
	OOB data: Authentication data not present (0x00)
	Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: Command Complete (0x0e) plen 10
	IO Capability Request Reply (0x01|0x002b) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: User Passkey Request (0x34) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: User Passkey Request Reply (0x01|0x002e) plen 10
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Passkey: 599207
> HCI Event: Command Complete (0x0e) plen 10
	User Passkey Request Reply (0x01|0x002e) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Simple Pairing Complete (0x36) plen 7
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 560e9c31d700ae5576af83d1e079e911
	Key type: Authenticated
	Combination key from P-192 (0x05)

Change-Id: Ia15517519b326eede29bc8e71edb7ec6ca77e010
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:12:01 +00:00
Arkadiusz Lichwa
143a826b1e Bluetooth: BR/EDR: Handle User Passkey Notify event
To allow remote, typically a keyboard, input on its side common
passkey during SSP authentication, enable generated passkey value by
local controller to be notified to user interface if available.

> HCI Event: IO Capability Response (0x32) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: KeyboardOnly (0x02)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: IO Capability Request (0x31) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: DisplayYesNo (0x01)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM required (0x01)
> HCI Event: Command Complete (0x0e) plen 10
	IO Capability Request Reply (0x01|0x002b) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: User Passkey Notification (0x3b) plen 10
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Passkey: 831705
> HCI Event: Simple Pairing Complete (0x36) plen 7
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 1a8d1c80409c4466b3423ca2bb761cf4
	Key type: Authenticated Combination key from P-192 (0x05)
> HCI Event: Encryption Change (0x08) plen 4
	Status: Success (0x00)
	Handle: 11
	Encryption: Enabled with E0 (0x01)

Change-Id: I1e8ad5d75181ceb9c93576b9e9b93975d9cdf35b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:11:49 +00:00
Arkadiusz Lichwa
7b2799da1c Bluetooth: BR/EDR: Handle User Confirmation Request event
Enables processing, as pairing acceptor, user interactive passkey
confirmation request if local and remote IO Capabilities supports
'display yes/no'. Based on such validation, both parties can confirm
interactively passkey value or JustWorks (auto-accept) model is used.

> HCI Event: Command Complete (0x0e) plen 10
	IO Capability Request Reply (0x01|0x002b) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: User Confirmation Request (0x33) plen 10
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Passkey: 565990
< HCI Command: User Confirmation Request Reply (0x01|0x002c) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10
	User Confirmation Request Reply (0x01|0x002c) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Simple Pairing Complete (0x36) plen 7
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)

Change-Id: Ice7a57a1c6150c10ea22402554954ed84aa94d0e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:10:47 +00:00
Arkadiusz Lichwa
02f541dfc5 Bluetooth: BR/EDR: Reply to IO Capability request
For now as local host works as pairing acceptor, the pairing context
flag is set when remote IO Capabilities is received.
Reply to the request uses remote's authentication requirement
cross-checked against predefined authentication methods that are based
on local and remote IO capabilities.

> HCI Event: IO Capability Response (0x32) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: NoInputNoOutput (0x03)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM not required (0x00)
> HCI Event: IO Capability Request (0x31) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	IO capability: DisplayYesNo (0x01)
	OOB data: Authentication data not present (0x00)
	Authentication: No Bonding - MITM not required (0x00)
> HCI Event: Command Complete (0x0e) plen 10
	IO Capability Request Reply (0x01|0x002b) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)

Change-Id: I0f95a58178618f06de16cce0e9d9cf6c85209677
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:09:55 +00:00
Arkadiusz Lichwa
befb051595 Bluetooth: BR/EDR: Validate remote requirements
According Core Spec 4.2 [Vol 2 Part E, 7.7.41], remote authentication
and IO capability requirements have defined valid ranges.

Change-Id: I0f7cfb79097abbf96b3fee79a757431b6beef665
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:03:00 +00:00
Arkadiusz Lichwa
4e063354e9 Bluetooth: BR/EDR: Mark P-192 EC link key as AUTHENTICATED
When link key generated by controller is derived from applied
non-JustWorks authentication method by using P-192 elliptic curve (EC)
algorithm, mark it as authenticated.

< HCI Command: User Confirmation Request Reply (0x01|0x002c) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10
	User Confirmation Request Reply (0x01|0x002c) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Simple Pairing Complete (0x36) plen 7
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 1f0a22d608ee0025c2faea0282bd2479
	Key type: Authenticated Combination key from P-192 (0x05)

Change-Id: Id2afbdc9eb1b2ef66e850c4a53b91187b88e5c6b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:02:12 +00:00
Arkadiusz Lichwa
3f6fdacdc6 Bluetooth: BR/EDR: Reuse link key if available
When link key exists in keys database and subsequent connection wants
to use it, reassign such link key to corresponding connection object.

< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
	Address: 68:17:29:CF:5D:86 (Intel Corporate)
	Role: Slave (0x01)
> HCI Event: Command Status (0x0f) plen 4
	Accept Connection Request (0x01|0x0009) ncmd 1
	Status: Success (0x00)
> HCI Event: Connect Complete (0x03) plen 11
	Status: Success (0x00)
	Handle: 72
	Address: 68:17:29:CF:5D:86 (Intel Corporate)
	Link type: ACL (0x01)
	Encryption: Disabled (0x00)
> HCI Event: Link Key Request (0x17) plen 6
	Address: 68:17:29:CF:5D:86 (Intel Corporate)
< HCI Command: Link Key Request Reply (0x01|0x000b) plen 22
	Address: 68:17:29:CF:5D:86 (Intel Corporate)
	Link key: 62329a517ec1664361c6578e67e71f22
> HCI Event: Command Complete (0x0e) plen 10
	Link Key Request Reply (0x01|0x000b) ncmd 1
	Status: Success (0x00)
	Address: 68:17:29:CF:5D:86 (Intel Corporate)
> HCI Event: Encryption Change (0x08) plen 4
	Status: Success (0x00)
	Handle: 72
	Encryption: Enabled with E0 (0x01)

Change-Id: I409904dc739e600d3418f7d3ffb1a2dc9ea3a411
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-21 11:01:59 +00:00
Johan Hedberg
b84f60cab3 Bluetooth: Move stack analysis helper to a global location
The helper for analyzing (fiber) stack usage is in no way specific to
Bluetooth and will likely be of use to many other places as well. Move
it therefore to include/misc.

Change-Id: Iedb699dbe248aca305e387998d37bb339cfb0e21
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-17 16:29:05 +00:00
Johan Hedberg
e4e04adb88 Bluetooth: Call HCI_Reset synchronously to catch errors
Change-Id: I882ec6ce5823afbf3cd423c36e0ac740c69574ce
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Johan Hedberg
54f5600fb5 Bluetooth: Take advantage of hci_cmd_done() helper
Change-Id: Id4945656407e567dcfe764d5d4df04427c8483af
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Johan Hedberg
809a4b847f Bluetooth: Fix print format for 4-byte opcodes
Change-Id: Ie37a6e02a5c024ccc02a2dbb17f30b16a4043406
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-14 18:05:24 +02:00
Arkadiusz Lichwa
dcd04f2a68 Bluetooth: BR/EDR: Add pairing mode flag
Since right now the stack supports as acceptor pre-2.1 devices pairing,
start set the state pairing flag in legacy PIN request handler and
resets it on Encryption Changed event.
When connection is 'in-pairing' mode disallow of local user to trigger
change security level on link.

> HCI Event: Command Status (0x0f) plen 4
	Accept Connection Request (0x01|0x0009) ncmd 1
	Status: Success (0x00)
> HCI Event: PIN Code Request (0x16) plen 6
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: PIN Code Request Reply (0x01|0x000d) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	PIN length: 4
	PIN code: 1234
> HCI Event: Command Complete (0x0e) plen 10
	PIN Code Request Reply (0x01|0x000d) ncmd 1
	Status: Success (0x00)
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link key: 2a4eae1018ed248064166e765d946313
	Key type: Combination key (0x00)
> HCI Event: Connect Complete (0x03) plen 11
	Status: Success (0x00)
	Handle: 12
	Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
	Link type: ACL (0x01)
	Encryption: Disabled (0x00)
> ACL Data RX: Handle 12 flags 0x02 dlen 10
	L2CAP: Information Request (0x0a) ident 1 len 2
	Type: Extended features supported (0x0002)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5
	Num handles: 1
	Handle: 12
	Count: 1
> HCI Event: Encryption Change (0x08) plen 4
	Status: Success (0x00)
	Handle: 12
	Encryption: Enabled with E0 (0x01)

Change-Id: I5cbdaab1d6d52197795bfffd465ba59216afee00
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-09 12:41:44 +00:00
Arkadiusz Lichwa
aaa2650f0f Bluetooth: Cleanup dependency build for LE/BREDR
Reorganizes mostly by using preprocessor (indirectly Kconfig options)
strictly LE-SMP related interfaces and security interfaces shared
between LE and BREDR connections.

Change-Id: I90daa36d72403cd5b73e6791714fcaf7f1fbe8e5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-03-09 10:55:31 +00:00
Arkadiusz Lichwa
847a1f6628 Bluetooth: BR/EDR: Add initial SSP Complete
Adds HCI protocol type for Secure Simple Pair Complete event and enables the
event in controller.
Then implements the initial SSP Complete event handler with catching
the status of SSP process.

Change-Id: Ic7cc5b4cab8a1b4120285815c24eeb6483d748df
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 08:43:31 +00:00
Arkadiusz Lichwa
2697d4fd5e Bluetooth: BR/EDR: Initial IO Capability reply to remote
Enables IO Capability Request event in controller.
Adds handler to react on controller's IO Capability Request event during
incoming pairing.
As a initial case respond to the request with negative reply setting
reason as 'pairing not allowed'.

Change-Id: I161c7ab7f1031a78cfa50444f41624232e5c5146
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 08:42:57 +00:00
Arkadiusz Lichwa
dd8bf892f3 Bluetooth: BR/EDR: Handle IO Capability Response event
Enables IO Capability Response event in controller and adds remote IO Capability
and authentication fields to connection object.
Initializes them using IO exchange values delivered in SSP IO Capability
Response event data set representing remote as a part of incoming pairing
process.

Change-Id: Ia73a912f6fb633d1d1bb086ef3af9a280ac5a864
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 06:22:54 +00:00
Arkadiusz Lichwa
73e201cbce Bluetooth: BR/EDR: Enable SSP mode in controller
Turns on Secure Simple Pairing mode in controller. Since there's a prerequisite
the controller is 4.0+, turning the mode is unconditional.

Change-Id: Id4a10ccf8892a430b0daaa6750835516b17b7e8a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-26 06:05:31 +00:00
Arkadiusz Lichwa
0abd5dd7d5 Bluetooth: BR/EDR: Rename local variable
Changes the local netbuff name to be more generic and to be used later in code
initializing BR/EDR stack.

Change-Id: Iae177237c813a46cbd10720a7af3474632154678
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-25 10:37:55 +00:00
Szymon Janc
b7b0a16a07 Bluetooth: Fix tracking of advertising state
This fix not being able to stop advertising while connected due to
invalid use of BT_DEV_ADVERTISING flag.

Change-Id: If5578fa2c69dd18d6623d05ae44d4710cce9a9e5
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-17 13:15:08 +00:00
Szymon Janc
4dfb50e514 Bluetooth: Fix not calling connected callback on connect failed
If LE Create Connection fails notify application that connection
failed.

Change-Id: I3993bcb1bf3f8bd8fc08546e1fe683326b47db5b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-17 13:07:46 +00:00
Arkadiusz Lichwa
1246df3c98 Bluetooth: BR/EDR: Validate security on encryption key refresh evt
During endup pairing as acceptor update security level on encryption key
refresh complete event.

Change-Id: Id1d252bfa5a7f6c69d52b3f6b23907025e711fb2
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-16 06:51:31 +00:00
Arkadiusz Lichwa
9c88e66935 Bluetooth: BR/EDR: Validate security on encryption change evt
During endup pairing as acceptor update security level on encryption change
event.

Change-Id: Icddedc09f70093cc05ac99d04053b3bd3ef22555
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-16 06:51:10 +00:00
Arkadiusz Lichwa
bd81052d41 Bluetooth: BR/EDR: Validate security on connection complete evt
During endup pairing as acceptor update security level and link encryption
state on connection complete event.

Change-Id: I6189a3c6675c080e3ab2610c81b617294dbd98d5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 20:46:19 +00:00
Arkadiusz Lichwa
ac7e560ba9 Bluetooth: BR/EDR: Move part of BR/EDR core code up
To skip around forward declaration in next security update patch,
move up part of strictly BR/EDR related code.

Change-Id: Id44fc831f629e66660edbc43c187cbf9a88b771d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 19:52:46 +00:00
Arkadiusz Lichwa
998d72a986 Bluetooth: BR/EDR: Track 16 digits PIN code
As a pairing acceptor starts tracking 16 octets PIN entered by user
when pairing devices working in Security Mode 3. Based on PIN tracker
state, the generated link key is saved in keys database as combination of
un/authenticated and legacy key type.

Change-Id: I4cbb20942fb38697d952971df807aec8b16c74e4
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-15 17:19:40 +00:00
Johan Hedberg
1bc6597d4d Bluetooth: Take advantage of the new net_buf_pull_u8() helper
Change-Id: I41ac2bc721b916f6d939f23be293750a83d21523
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 16:03:43 +00:00
Johan Hedberg
984c7a6945 Bluetooth: Kconfig: Introduce BLUETOOTH_RX_STACK_SIZE
Applications may want to fine-tune the stack size of the fiber that's
used to make callbacks into the application.

Change-Id: I2cd3e79283fe85359389528e84d9bcc21e3e19f6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-12 13:01:13 +02:00
Szymon Janc
8dbd8dcc5b Bluetooth: Remove dead code
Since now TinyCrypt is always enabled there is no need for HCI
backup code.

Change-Id: I6cf9c2bd15dc9a6c0dd98cd7aff0ea137eb0be8b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-11 20:44:44 +00:00
Johan Hedberg
4c11dda411 Bluetooth: Take advantage of the new net_buf_add_u8() helper
Change-Id: Id062d4f68be1960006926ddf463c2c7ecf42d31a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-11 14:48:03 +02:00
Szymon Janc
708126cd30 Bluetooth: Use correct CONFIG option for TinyCrypt ECC define
The option is named CONFIG_TINYCRYPT_ECC_DH.

Change-Id: Ice30857d368582f5bc5d2f47e8ce6b1a89e29128
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:01 -05:00
Szymon Janc
6de50c5aa6 Bluetooth: Store LE SC Public Key in SMP code
There is no need to keep this in bt_dev structure as this is not
used outside of SMP code.

Change-Id: I24a1d9daffb4d382bf1ed07a5645e4cbdafa3c5e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:01 -05:00
Szymon Janc
47ecb52064 Bluetooth: Add support for TinyCrypt based bt_rand
This allows to use pseudo random numbers generator provided by
tinycrypt instead of constant using of HCI LE Rand command.

HCI LE Rand commands are used only to initialize and re-seed PRNG.

Using tinycrypt for NRPA increase size of sample shell application
from 86852 to 89700 bytes.

Change-Id: I06e7392d087908caf37cd3ae648ea0bd5cc4ce61
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 19:13:00 -05:00
Louis Caron
48802c2212 Bluetooth: Add API to update LE connection parameters
Applications should be able to update the connection parameters.

Change-Id: I446f64fcd0b27b605e636e566fb35a362a92de96
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:33 -05:00
Johan Hedberg
479d25d035 Bluetooth: Rename BT_LE_ADV_ADDR_PUBLIC to BT_LE_ADV_ADDR_IDENTITY
In anticipation of supporting a local static random address in the
future it makes more sense to call BT_LE_ADV_ADDR_PUBLIC
BT_LE_ADV_ADDR_IDENTITY.

Change-Id: I4826f1dfb50b54e13a35cbe7ee74e28641c81ad1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:31 -05:00
Johan Hedberg
a9404225e5 Bluetooth: Use NULL for "any" connection with bt_conn_lookup_state_le()
An all zeroes address is in principle not valid, but prototype devices
have been seen using it. To avoid false-positives with the
bt_conn_lookup_state_le() API use a NULL pointer rather than
BT_ADDR_LE_ANY to indicate that any connection in the specified state
is of interest.

Change-Id: I42a1946e47173b17be295b1b7e97a654dbdcdc6a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:28 -05:00
Szymon Janc
719e8e4710 Bluetooth: Fix not updating LE keys on Key Refresh Event
If link is already encrypted controller issues "Encryption Key
Refresh Complete" for "LE Start Encryption".

Failing to update keys resulted in invalid security level being set.

Change-Id: I8d8dd1682937bd35a35111366ec6ebdaa619db7c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:28 -05:00
Arkadiusz Lichwa
ea3b162bac Bluetooth: BR/EDR: Add support for Link Key request
Delivers a valid Link Key to controller if found or responds negative
to Link Key request to controller.

Change-Id: I98061110a60b066421f35db44455925cbcd3076e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:25 -05:00