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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
This makes it easier to track issues resulting from missing ECDH
support.
Change-Id: Iab104beed8cc622ea7bec2275ed69ca4ffe4cc87
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
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>
Removes redundant parameter value to be printed.
Change-Id: Ib719135b4f99265312b3a08f051d35d10adb0bcf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
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>
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>
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>
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>
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>
Some non-ASCII characters were used in code comments.
Change-Id: Ie00e0b7d7a42a50503c601225cdd0896c375dee3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
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>
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>
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>
Add new bt_dev flag for tracking if performing active scan.
Change-Id: I7eacaa94372bae933f648a49d2f55fc200f9d0bf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
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>
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>
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>
Some non-ASCII characters were used in code comments.
Change-Id: I77f13ca1648f34dc5dbd9ea78ccd2964a73a1712
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
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>
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>
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>
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>
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>
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>
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>
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>
16 bit handles have to be converted to host order.
Change-Id: Iae5d9d79bacd90cd5b42a98d02165ec75bf1272e
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
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>
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>
We already have host order length in len variable.
Change-Id: I5b4ea652c5709eadd64b66584024501c40fd3abc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
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>
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>
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>
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>
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>