Commit Graph

1158 Commits

Author SHA1 Message Date
Flavio Santes e6ffc0ed28 crypto: Update tinycrypt source files
Update Zephyr's tinycrypt to version 2.0. This new version adds support
for ECC_DH, ECC_DSA, CMAC, & CTR_PRNG.

The following doxygen documentation typos were detected and fixed:

- ctr_prng.h:84 change plen by pLen,
- ctr_prng.h:109 change entropylen by entropyLen,
- sha256.h:110 change Sha256 by s.

ecc_dh.h is also modified to fix the discrepancy of ecc_make_key
definition and declaration.
See https://gerrit.zephyrproject.org/r/#/c/1982/

TC_FAIL and TC_SUCCESS defines are renamed in this new version of
tinycrypt, so net/bluetooth/hci_core.c, net/bluetooth/hci_ecc.c and
net/bluetooth/smp.c are also updated to reflect those changes.

Origin: https://github.com/01org/tinycrypt/archive/v0.2.0.tar.gz

Jira: ZEP-590

Change-Id: I85f4f0ab61d9b0be6a60897e2b96f245dd8c51a8
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-07-27 21:33:42 +00:00
Johan Hedberg 9915378e8c Bluetooth: Take advantage of ATOMIC_DEFINE atomic_t based flags
Using ATOMIC_DEFINE removes the risk of the number of flags growing
past 32 and thereby causing an overflow of the flags variable.

Change-Id: Id3679a5a1b567b2681bc5bbd6384ed88478a32d6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-27 17:14:59 +00:00
Luiz Augusto von Dentz 5194d2fb06 Bluetooth: GATT: Remove unused struct
prepare_write_data is no longer need since the ATT layer is now
responsible to queue the prepare writes using regular writes to commit
the data instead.

Change-Id: I8e35307a0489505b1475cdf31773c65a51165539
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-27 15:28:38 +03:00
Luiz Augusto von Dentz 78881ebd3b Bluetooth: GATT: Fix not passing params in the write callback
Write callback shall receive the params given in the request so the
struct itself needs to be passed.

Change-Id: Ia039c25c99efb57e4c441561067d0398d9e6277c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-26 15:26:15 +03:00
Arkadiusz Lichwa ea5449dbcc Bluetooth: L2CAP: Add BR/EDR CoC channel disconnect
Implements CoC channel disconnect API initiated from local and handles
response to the disconnect request from remote.

Change-Id: I25f2495404cd405dc83ad56269e4897e53d602e6
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:24:04 +00:00
Arkadiusz Lichwa a49b9fcf57 Bluetooth: L2CAP: Handle BR/EDR configuration deferred by GAP
Marks successfuly allocated channel during incoming connection
request to dedicated channel context flag. Introduced here ACCEPTOR
role on L2CAP layer helps then resolve channel CoC state context when
incoming connection setup is deferred by changed security on GAP caused
by local L2CAP channel requirement.

> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 108.666944
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.668572
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.673002
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.673548
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.674725
      L2CAP: Configure Request (0x04) ident 5 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.707579
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 108.714206
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 560
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 108.715442
      L2CAP: Configure Response (0x05) ident 5 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.720451
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14                   [hci1] 108.720472
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.722324
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.976574
        Num handles: 1
        Handle: 12
        Count: 1
> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 116.297981
      L2CAP: Connection Request (0x02) ident 5 len 4
        PSM: 5 (0x0005)
        Source CID: 65
< HCI Command: Authentication Requested (0x01|0x0011) plen 2  [hci1] 116.302176
        Handle: 12
> HCI Event: Command Status (0x0f) plen 4                     [hci1] 116.303129
      Authentication Requested (0x01|0x0011) ncmd 1
        Status: Success (0x00)
> HCI Event: Link Key Request (0x17) plen 6                   [hci1] 116.304127
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 116.304327
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 116.305841
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection pending (0x0001)
        Status: Authentication pending (0x0001)
< HCI Command: Link Key Request Negat.. (0x01|0x000c) plen 6  [hci1] 116.306913
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 116.308125
      Link Key Request Negative Reply (0x01|0x000c) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: IO Capability Request (0x31) plen 6              [hci1] 116.309126
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
< HCI Command: IO Capability Request... (0x01|0x002b) plen 9  [hci1] 116.310177
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        IO capability: DisplayYesNo (0x01)
        OOB data: Authentication data not present (0x00)
        Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 116.311125
      IO Capability Request Reply (0x01|0x002b) ncmd 1
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: IO Capability Response (0x32) plen 9             [hci1] 116.331128
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        IO capability: DisplayYesNo (0x01)
        OOB data: Authentication data not present (0x00)
        Authentication: Dedicated Bonding - MITM required (0x03)
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 116.483125
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: User Confirmation Request (0x33) plen 10         [hci1] 116.516225
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        Passkey: 798417
< HCI Command: User Confirmation Requ.. (0x01|0x002c) plen 6  [hci1] 123.541708
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Command Complete (0x0e) plen 10                  [hci1] 123.555708
      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            [hci1] 131.484303
        Status: Success (0x00)
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
> HCI Event: Link Key Notification (0x18) plen 23             [hci1] 131.524232
        Address: 00:1A:7D:DA:71:13 (cyber-blue(HK)Ltd)
        Link key: 9355f679935c4e602ac1cc8a56ba121a
        Key type: Authenticated Combination key from P-192 (0x05)
> HCI Event: Auth Complete (0x06) plen 3                      [hci1] 131.525244
        Status: Success (0x00)
        Handle: 12
< HCI Command: Set Connection Encrypt.. (0x01|0x0013) plen 3  [hci1] 131.527348
        Handle: 12
        Encryption: Enabled (0x01)
> HCI Event: Command Status (0x0f) plen 4                     [hci1] 131.528234
      Set Connection Encryption (0x01|0x0013) ncmd 1
        Status: Success (0x00)
> HCI Event: Encryption Key Refresh Complete (0x30) plen 3    [hci1] 131.552238
        Status: Success (0x00)
        Handle: 12
> HCI Event: Encryption Change (0x08) plen 4                  [hci1] 131.553240
        Status: Success (0x00)
        Handle: 12
        Encryption: Enabled with E0 (0x01)
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 131.556727
      L2CAP: Connection Response (0x03) ident 5 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 131.562063
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 65
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 64
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 131.562733
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 65
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 245
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 131.567286
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 131.568858
      L2CAP: Configure Response (0x05) ident 6 len 10
        Source CID: 65
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 64

Change-Id: I04aab5a0511ba09693f96faeeb66eef53e66ce0e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:23:12 +00:00
Arkadiusz Lichwa f8f9de079a Bluetooth: L2CAP: Reset CoC channel state during cleanup
When user channel is disattached from connection object during channel
cleanup, resets its state to DISCONNECTED to be able reuse it from
well known init state.

Change-Id: I5733ade4be195821a1643383916c3a6fea5a88d3
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:22:57 +00:00
Arkadiusz Lichwa 37bb3e8049 Bluetooth: L2CAP: Split security changed handler for BR/EDR
Delegates own handler for changed security information happened on BR/EDR
link. Now L2CAP layer based on transport type can independently handle
updated security information.

Change-Id: I4838f1cc9d53cf6dfab19bb9f70ec6e307741e66
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 14:22:18 +00:00
Arkadiusz Lichwa 96e68fe654 Bluetooth: L2CAP: Introduce security requirements on CoC
Applies on L2CAP channel object security requirement member and
implements on BR/EDR transport basic security cases during incoming
CoC connection request. Since channel security requirements can involve
sending 2 separate connection responses with proper results depending on
context path, there's a need to store L2CAP signaling identifier set in
original connection request to be restored later to help match proper
response context.

Change-Id: Ibac9a5d2443f2975637e1bd15f61afcad53f843b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-25 13:56:08 +00:00
Szymon Janc d2549115ca Bluetooth: Rename connectable_addr member in struct bt_le_oob
Depending on advertising options this can be non-connectable address.
NFC pairing application document also allows broadcaster/observer
roles.

Change-Id: I9b104ac8fb9752a083a7a31fc20598c66f23f608
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-22 13:09:30 +02:00
Arkadiusz Lichwa d5a07edde0 Bluetooth: L2CAP: Refactor channel context by ident
Moves 'ident' member so far included in bt_l2cap_le_chan context only
to common bt_l2cap_chan context. The change is driven by sharing ability
to store/restore 'ident' on both transports and makes use of it only if
CoC is configured. For default configuration there's channel addition
helper to be used internally by dedicated macros managing channel
objects enlisted in connection tracker list.
The common member is used in matching outstanding connection responses
on LE and to prepare a ground for BR/EDR transport context when
there'll be a need to match response to original incoming connection
request after in-between security changes that can happen.

Change-Id: I1a4cad7cd53c74774604a0e9794607081a8b6e80
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-22 09:20:20 +00:00
Luiz Augusto von Dentz c9a3809ab5 Bluetooth: Remove nano_work include from internal header
This include is no longer necessary since all .c files that include it
already have nano_work included as well.

Change-Id: I523d6c756e2e49d53fcb00459d8ed547113d9078
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-22 09:18:13 +00:00
Johan Hedberg cbf325a58d Bluetooth: Add warning for bt_pub_key_gen() when missing support
This makes it easier to track issues resulting from missing ECDH
support.

Change-Id: Iab104beed8cc622ea7bec2275ed69ca4ffe4cc87
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-22 09:17:51 +00:00
Johan Hedberg d43f4c27d0 Bluetooth: Remove conn & SMP dependency from BLUETOOTH_TINYCRYPT_ECC
Ever since we expose ECDH as a more generic API that's not bound to
SMP we shouldn't be requiring selcting SMP in the configuration for it
to be available. Move it outside of the BLUETOOTH_SMP and
BLUETOOTH_CONN dependencies.

Change-Id: I4ac15ff92b1d4fcf3061a487718d364aa7d43bc8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-22 09:17:42 +00:00
Arkadiusz Lichwa 65ab753fe7 Bluetooth: L2CAP: Fix debug message in l2cap_chan_destroy
Removes redundant parameter value to be printed.

Change-Id: Ib719135b4f99265312b3a08f051d35d10adb0bcf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-22 09:00:09 +02:00
Kumar Gala 5249b8a52d Bluetooth: use sys_put_le16 macro instead of bswap
Use sys_put_le16 rather than having to explicitly have an ifdef
check in the code and use bswap_16.

Change-Id: Ia7b2b956c69993e29b1186da3d08e5eb449f096b
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2016-07-22 04:26:15 +00:00
Szymon Janc c6bcb591f6 Bluetooth: Add initial support for OOB data
This allows to query information needed for Out Of Band pairing
or connection creation. Currently supports only BT addresses.

Change-Id: I60bf9344baee552e7743fa8fc1b3cfb3a4765334
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 20:20:44 +02:00
Johan Hedberg 211ae314e8 Bluetooth: Pass net_buf_simple to scan callback
This lets the callback take advantage of the powerful net_buf API for
parsing the advertising data content.

Change-Id: Id65e6e83efd60c0f36c47bc5446a2e8ec2833d7c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-20 16:19:01 +00:00
Szymon Janc a0a52691f2 Bluetooth: Add support for rotating RPA
If privacy is enabled we always use RPA, even for active scan.
This makes single point of controlling current random address
making code simple and not prone to subtle bugs with concurent
advertising, scanning and connecting.

Currently used RPA is rotated to improve privacy. Timeout value is
controlled by Kconfig and by default is 900 seconds (15 minutes).

Change-Id: I27a15666a4f2e2962cf6eb20c7cd06f90b7f2bb1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-20 16:18:50 +00:00
Luiz Augusto von Dentz c51bcbb9d9 Bluetooth: GATT: Add write struct parameter to its callback
This makes bt_gatt_write consistent with the rest of the API where the
parameters are passed back to its callback.

Change-Id: Ie94208aa661d3620d0cbc5be4a4fb5b3c3ef061c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-20 13:40:55 +00:00
Szymon Janc ae96c91109 Bluetooth: GATT: Fix using non-ASCII characters
Some non-ASCII characters were used in code comments.

Change-Id: Ie00e0b7d7a42a50503c601225cdd0896c375dee3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-19 09:49:17 +00:00
Arkadiusz Lichwa 796d467653 Bluetooth: L2CAP: Set BR/EDR CoC channel as connected
Finalizes CoC channel configuration setup. The channel's CONNECTED state
can be set depending on context path by two responsible for that handlers.
Then one of them announces to all registered clients the connection is
set successfully.

> ACL Data RX: Handle 12 flags 0x02 dlen 12                   [hci1] 108.666944
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 3 (0x0003)
        Source CID: 64
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.668572
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.673002
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.673548
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16                   [hci1] 108.674725
      L2CAP: Configure Request (0x04) ident 5 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5        [hci1] 108.707579
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16                   [hci1] 108.714206
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 560
> ACL Data RX: Handle 12 flags 0x02 dlen 18                   [hci1] 108.715442
      L2CAP: Configure Response (0x05) ident 5 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5  [hci1] 108.720451
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14                   [hci1] 108.720472
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)

Change-Id: If831777f7bd87489eefbd200a1ca8883b83aae3e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:31:06 +02:00
Arkadiusz Lichwa 22bdf50615 Bluetooth: L2CAP: Mark finishing CoC configuration on BR/EDR
When each side involved in getting configured L2CAP CoC channel on
BR/EDR transport aggrees on configuration contract regarding in/out MTU,
set proper context flags to start prepare finalize config process.

Change-Id: Ic821ea3b961442be758ad4e2d91b2d812e2a54b5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 11:01:17 +02:00
Arkadiusz Lichwa c28720f167 Bluetooth: L2CAP: Introduce CoC channel states
Adds CoC channel's context to hold channel setup state and SM routine
that evaluates validness of transitions.
At the beginning DISCONNECTED, CONNECT and CONFIG states are added and
used by CoC setup on BR/EDR transport.

Change-Id: I1bbd16ec2f59ea961791786b78f22834d6f4b4d8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-15 04:54:03 +00:00
Szymon Janc c9e2fc1929 Bluetooth: Fix changing advertising random address when scanning
If active scan was started while advertising random adress was
set to NRPA. This results in device advertising with new adress
instead of RPA making it imposible to resolve its identity by
remote devices.

To fix this NRPA for active scan is set only if advertising is
not enabled. This resulst in RPA being used for scan requests
but this is OK since device is advertising anyway.

Change-Id: I35e98bee72f4abc033f5adc664698c14c5d8a2b0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:50 +00:00
Szymon Janc 40cf82bc60 Bluetooth: Track if active scan is being perfomed
Add new bt_dev flag for tracking if performing active scan.

Change-Id: I7eacaa94372bae933f648a49d2f55fc200f9d0bf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 15:26:42 +00:00
Szymon Janc 9303331bbd Bluetooth: SMP: Fix disabling debug logs
SMP debugs should be enabled only if CONFIG_BLUETOOTH_DEBUG_SMP is
defined.

Change-Id: I17f8ad5e1a9504dcbd3df545af9205db88ee2849
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-14 11:52:48 +02:00
Mariusz Skamra d98b9bd139 Bluetooth: Get the included service 128bit UUID
This adds reading of included service attribute 128bit UUID.
The limitation of this solution is that if several attr handle-range
pairs will be received, this will read first attribute UUID and then
start discovery from the the succeeding handle.

ZEP-373

Discovery related test results:

 2/76   GATT   TC_GAD_CL_BV_02_C   PASS
 3/76   GATT   TC_GAD_CL_BV_03_C   PASS
 4/76   GATT   TC_GAD_CL_BV_04_C   PASS
 5/76   GATT   TC_GAD_CL_BV_05_C   PASS
 6/76   GATT   TC_GAD_CL_BV_06_C   PASS

Change-Id: I27185b3a3ae96c9c03b0f356492df18ba83b183a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-13 14:18:03 +00:00
Szymon Janc 48eee87a39 Bluetooth: Fix using NRPA for connectable advertising
If privacy is disabled and static random address is used for identity
we need to restore static address before enabling advertising.
Otherwise NRPA used for any previous active scan could be used instead.

Change-Id: Ifea0d2863d78060c84e61d89ef384a94e86895b6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-13 04:53:22 +00:00
Szymon Janc 832b808177 Bluetooth: ATT: Fix using non-ASCII characters
Some non-ASCII characters were used in code comments.

Change-Id: I77f13ca1648f34dc5dbd9ea78ccd2964a73a1712
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-12 15:13:23 +00:00
Arkadiusz Lichwa ca57a7816d Bluetooth: L2CAP: Start servicing configuration request from remote
To make channel operational in basic mode a process of BR/EDR CoC
channel configuration needs to be performed in both directions. Remote
peer is mandated as well to inform local about its segmentation
requirements. Here is added such request handler focused on grabbing
remote MTU which is mandatory in channel setup.

> ACL Data RX: Handle 12 flags 0x02 dlen 12  [hci1] 12.133539
      L2CAP: Connection Request (0x02) ident 3 len 4
        PSM: 1 (0x0001)
        Source CID: 64
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.133631
        Num handles: 1
        Handle: 12
        Count: 1
> HCI Event: Number of Completed Packets (0x13) plen 5  [hci1] 12.133792
        Num handles: 1
        Handle: 12
        Count: 2
< ACL Data TX: Handle 12 flags 0x00 dlen 16  [hci1] 12.141644
      L2CAP: Connection Response (0x03) ident 3 len 8
        Destination CID: 64
        Source CID: 64
        Result: Connection successful (0x0000)
        Status: No further information available (0x0000)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.142054
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 16  [hci1] 12.143276
      L2CAP: Configure Request (0x04) ident 6 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
> HCI Event: Number of Completed Packets (0x13) plen 5  [hci1] 12.150945
        Num handles: 1
        Handle: 12
        Count: 2
> ACL Data RX: Handle 12 flags 0x02 dlen 16  [hci1] 12.150959
      L2CAP: Configure Request (0x04) ident 4 len 8
        Destination CID: 64
        Flags: 0x0000
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 128
> ACL Data RX: Handle 12 flags 0x02 dlen 18  [hci1] 12.152160
      L2CAP: Configure Response (0x05) ident 6 len 10
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
        Option: Maximum Transmission Unit (0x01) [mandatory]
          MTU: 48
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.158806
        Num handles: 1
        Handle: 12
        Count: 1
< ACL Data TX: Handle 12 flags 0x00 dlen 14  [hci1] 12.161822
      L2CAP: Configure Response (0x05) ident 4 len 6
        Source CID: 64
        Flags: 0x0000
        Result: Success (0x0000)
< HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5  [hci1] 12.163197
        Num handles: 1
        Handle: 12
        Count: 1

Change-Id: I7919fe180cf1d761023bb1478d8e1fb2d21a94d9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-11 19:34:17 +00:00
Luiz Augusto von Dentz d98068be94 Bluetooth: L2CAP: Fix not canceling RTX work
If the channel is being destroyed the RTX work should be cancelled as
it may cause destroy to be called again.

Change-Id: I49c10d64a2108719d28e456fb5b4bfb50ef8a140
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:40:39 +00:00
Luiz Augusto von Dentz a6a78bfbca Bluetooth: L2CAP: Unify code for adding and deleting channels
The code for adding and removing channels is very similar for LE and
BR/EDR so it can be unified and just leave the CID allocation up for the
bearer implementation.

Change-Id: Icf4c66262c4e973039381ebd1861fad4d46e1535
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:39:59 +00:00
Luiz Augusto von Dentz 2329d82432 Bluetooth: L2CAP: Make l2cap_chan_add initialize the destroy callback
This is cleaner and safer as destroy is garanteed to be initialized once
it is added to the list of channels.

Change-Id: Iae674f6e25527d71c03c5903337b0bd18c3dd0be
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-11 15:38:30 +00:00
Johan Hedberg 4efe39ff04 Bluetooth: SMP: Take advantage of new bt_hex helper
The h() helper isn't needed anymore.

Change-Id: Ica1b4beb086237c1c792d5376e8ee71bc64394fe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:44:13 +00:00
Johan Hedberg 6e701275af Bluetooth: Add hexadecimal conversion logging helper
This has so far been used in SMP code as the h() function. Now it has
a more generic name and is accessible by all parts of the Bluetooth
subsystem.

Change-Id: Iae4607da9c8b3e6779d9c97f84a4e486d5258ef0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:38:53 +00:00
Johan Hedberg f7d802b1e3 Bluetooth: Fix enabling ECDH HCI events when SMP is not selected
Now that there's an API always exposed for this the events should
always be enabled whenever the controller supports this feature.

Change-Id: I4965c9463ae7b3f6424784dab2c03403fdf3f179
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-11 09:38:42 +00:00
Szymon Janc bccc1bf0e1 Bluetooth: SMP: Send pairing failed on unexpected PDU
If unexpected PDU is recevied it is better to reply with Pairing
Failed and abort pairing then just silently ingore such PDU as
pairing will most likely fail anyway.

Change-Id: I3c67a6997a5e8d33b1e97cb955981a52baf38d02
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-09 12:40:48 +00:00
Luiz Augusto von Dentz 1183e6b82a Bluetooth: L2CAP: Add timeout handling
This adds initial timeout handling as described in the spec:

BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:

  'The value of this timer is implementation-dependent but the minimum
   initial value is 1 second and the maximum initial value is 60
   seconds. One RTX timer shall exist for each outstanding signaling
   request, including each Echo Request. The timer disappears on the
   final expiration, when the response is received, or the physical
   link is lost.'

Note: As for the actual interval used they are based on the values used
in Linux but in case of disconnect the minimum of 1 seconds was used
to follow the text above.

Change-Id: Ib98899c3ff07334955aee9c8fb53b1b89ba7bf31
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-08 12:05:33 +00:00
Luiz Augusto von Dentz 076ed6bc13 Bluetooth: ATT: Add timeout handling
Accourding to the spec request should have a timeout of 30 seconds:

BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part F] page 480:

  'A transaction not completed within 30 seconds shall time out. Such a
   transaction shall be considered to have failed and the local higher
   layers shall be informed of this failure. No more attribute protocol
   requests, commands, indications or notifications shall be sent to the
   target device on this ATT Bearer.'

Change-Id: I5e5b9fb008d3019831c5f6cc3bd4c2b85dd6b90a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-08 12:05:33 +00:00
Mariusz Skamra 6f11245d92 Bluetooth: Fix missing endian conversion
16 bit handles have to be converted to host order.

Change-Id: Iae5d9d79bacd90cd5b42a98d02165ec75bf1272e
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-07 06:04:33 +00:00
Luiz Augusto von Dentz 96b9425a64 Bluetooth: L2CAP: Only call disconnected callback for connected channels
If channel has conn set to NULL disconnected shall not be called as
may cause invalid actions as with bt_gatt_disconnected being called
with a NULL conn.

Change-Id: I11bc41a34c2a2a3bc5f8514ec4a948235473cfba
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-06 12:08:53 +00:00
Mariusz Skamra 2dda2a9835 Bluetooth: Use LE Rand workaround for MyNewt on Quark SE Devboard
LE Rand command crashing the MyNewt HCI firmware issue has been also
observed on Quark SE Devboard. Applying this workaround solves the problem.

Change-Id: I57a533309ced0b2d31517a65ac1899ed55112973
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-07-06 12:08:42 +00:00
Szymon Janc ad281d4dbe Bluetooth: L2CAP: Avoid double endianess convertion
We already have host order length in len variable.

Change-Id: I5b4ea652c5709eadd64b66584024501c40fd3abc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-07-06 12:08:31 +00:00
Arkadiusz Lichwa fdfc92c80d Bluetooth: ATT: Fix ATT_CHAN() macro
ATT_CHAN() macro as a wrapper to CONTAINER_OF is been used by ATT
internals API wherein the main parameter is pointer to bt_l2cap_chan
object. The macro returns pointer to bt_att context object but
CONTAINER_OF's third parameter determines what member is taken into
account in getting right address. Luckily here this third parameter
"chan" of type bt_l2cap_le_chan got of its own sub-member the "chan" of
type bt_l2cap_chan on first position in structure order. If such order
would change somehow there could be taken wrong address.

Change-Id: I955c2af11e001dac90a1eacc281ff167ceb34fb9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-07-05 16:52:05 +02:00
Johan Hedberg f1a82f8ebe Bluetooth: Fix incorrect public key size
The ECC public key is 64 bytes in length.

Change-Id: I0fec312cdd94ff181abf8ec7e4eab46e1dc11eb6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-03 17:07:48 +03:00
Luiz Augusto von Dentz b008f74b0b Bluetooth: L2CAP: Fix not cleanup properly if ACL is disconnected
If ACL is disconnected with channels still active the code should call
l2cap_chan_del to clean it up properly.

Change-Id: Iffa9345a9697ac80c1f2295578c7161ffeb44420
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-07-01 14:17:06 +00:00
Johan Hedberg 179f08f049 Bluetooth: Create proper abstraction for ECC access
This makes the SMP usage of ECC functionality properly encapsulated
and offers the chance of other protocols to utilize the functionality
in the future.

Change-Id: Iae14beafd5f8f7dbe2c6ffd33700471b8a62b8da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-07-01 11:21:04 +03:00
Szymon Janc 19ff3d3e37 Bluetooth: Print events opcodes as hex
This makes logs easier to read as those are defined as hex values.

Change-Id: I67f1dc0da9056a69398faf55fd5535a67ec4ebb9
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-06-30 16:05:59 +00:00
Arkadiusz Lichwa caf83c96ed Bluetooth: L2CAP: Make public helper for LE channel conversion
Replaces all occurences of LE_CHAN() macro with new name
BT_L2CAP_LE_CHAN() and makes it public.

Change-Id: I426b17b0214f7ab4b69e5febbdca1917f22e7487
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-06-30 09:06:35 +00:00