29 Commits

Author SHA1 Message Date
arnulfrupp 928c78a01b [tcat] implement rate limitation for TCAT TLVs 0x10, 0x11 and 0x12 and remove TLV 0x14 (#12211)
This commit implements rate limitation for the TCAT commands Present
PSKd Hash TLV (0x10), Present PSKc Hash TLV (0x11) and Present
Install-code Hash TLV (0x12) to prevent password guessing attacks.

It also removes the TCAT command Request PSKd Hash TLV (0x14), to
prevent offline password guessing attacks with a single Hash value
retrieved from the device.

Note: The commit does not remove the Request PSKd Hash TLV
implementation in the Python commissioner such that the non-existence
of the command TLV can still be tested.
2026-05-04 07:10:19 -07:00
Esko Dijk ea56e75ffe [tcat] fix CommCert4 to be signed by the correct CA (#12874)
Now signed by the correct 'Thread Certification DeviceCA'. A 'test'
target is added in the Makefile to test chaining.  The Thread
certification CA certificate is also added in the 'CA' directory,
which was missing.  Documentation is updated to clarify that the
'TcatCertCa' private key is not included in this repo; and other
clarifications.
2026-04-12 21:51:10 -05:00
Esko Dijk 9b663f384e [tcat] Update TCAT Commissioner authorization checks; add unit tests (#12182) (#12182)
Updates the TCAT class public methods for doing Commissioner
authorization checks and clarifies the code, with minor updates to
PSKc cases handling.

Unit tests are added for checking Commissioner authorization. To do
these checks, a new test class UnitTester is added which has access to
private members of the TcatAgent class.  Validation/mock functions are
added in the test code to keep the unit tests readable.

Also reverts the CommCert4 fix that was made in #12151.

For more background information see JIRA BHC-766.
2026-03-06 00:28:02 -06:00
Esko Dijk f121ebcffa [tcat] enable TCAT Commissioner to receive Alerts/TLV events over TLS and improve connection mgmt (#12011)
This enables the TCAT Commissioner to receive data such as TLS Alerts,
or asynchronously sent 'event' TLVs, over TLS.  Processing TLS Alert
is required to detect the sending of Alert by the TCAT Device, which
is a requirement to be verified in cert tests. An async background
process is started to receive and log the received events.

Also some minor improvements in connection state management: when
certain commands are given after the TCAT link is disconnected, or
when a TCAT link could not be established, a message will be printed
to clearly say it's disconnected, instead of a cryptic error. Error
messages are now clearly prefixed with 'Error:'.

The CA certificate store for CommCert3 is extended with an additional
CA certificate, so that it can be verified in cert tests that a TCAT
Device rejects a wrong Commissioner with a TLS Alert (previously this
couldn't be tested).

Also includes a fix of the pyproject.toml such that Poetry does not
display the long warning on installation.

Also includes an improvement of TLV displaying to the user with a
STRING field, if the value is a string.

Also includes some syntax fixes that were flagged by the IDE, such as
missing return types for methods, or member variables that were not
initialized in the __init__().
2026-01-27 14:24:48 -08:00
Esko Dijk 76f3418796 [tcat] fix in authorization for CommCert4 used in cert test TCAT-13.7, step 19 Decommission (#12151) 2025-11-18 11:00:15 -08:00
Esko Dijk d732acc6c6 [tcat] fix missing Python modules in tcat-ble-client pyproject.toml; bump module versions (#11984)
This fixes the issue that some required Python modules were missing in
pyproject.toml. To avoid Python version conflicts with the
cryptography module, the minimum Python version is raised to
3.10. Also, the name, version and description of the project are
updated. Module versions are updated to recent (2025) versions.

For Windows, a platform-specific import of pyreadline3 is added. Due
to this conditional dependency, the poetry.lock file is removed from
the repository: it is now necessarily specific to each platform and
has to be locally generated.
2025-10-07 10:45:31 -07:00
Esko Dijk 911820471e [tcat] improve TCAT Commissioner output logging for SSL errors (#11906)
This commit provides more structured logging for ssl.py errors, and
displays the OpenSSL verify error code. This is used for certification
to validate reasons of handshake failure.
2025-10-06 10:02:40 -07:00
Esko Dijk 3431162a09 [tcat] improved debug info format using hexadecimal + ASCII dump (#11881)
This improves debuggability of TCAT client and server, by using one
unified format (hex + ASCII) to show transmitted and received TCAT
data within the TLS session, as well as showing size of the encrypted
(TLS) data. For encrypted data, only size is now shown to avoid
clutter.  Showing the hex + ASCII dump allows devs/testers to visually
read TCAT TLVs from screen and identify how all TCAT commands are
processed by the Thread device.
2025-09-09 09:11:05 -07:00
arnulfrupp bb5585d412 [tcat] add tcat implementations and bug fixes (#11402)
Commit adds check if commissioning is possible and if the tcat device is already commissioned.
Adds advertisement update on disconnected and role change.
Fixes key handling for key references.
Fixes the authorization processing.
Implements recent changes of the application TLVs.
2025-07-30 12:27:10 -07:00
arnulfrupp d9d5b2e2c6 [tcat] implement get diagnostic tlvs in command class commissioning (#11163)
Adds implementation of Tcat TLV 0x26 Get Diagnostic TLVs.
It also adds support for long BleSecure messages >1280 bytes in BleSecure::Flush(void).
2025-04-14 09:22:58 -06:00
Przemysław Bida 4d6def38a5 [tcat] implement extraction of active dataset and commissioner cert (#10991)
Commit adds implementation of:
	- 0x40 Tcat tlv extraction of active dataset,
	- 0x25 Tcat tlv extraction of commissioner certificate.

Includes also refactoring of `BleCommand` adds new method `process_response`.
This simplifies:
- `GetPskdHash`
- `GetRandomNumberChallenge`
2025-01-21 08:43:19 -08:00
Jakub Uliarczyk 9942b98a4a [tcat] add tlv command tree (#11077)
This commit adds 'tlv' command tree to the BBTC CLI.
The 'tlv' command has two subcommands: 'list' and 'send'.
The 'tlv list' prints available TLVs types that can be used in the 'send' subcommand.
The 'tlv send <TLV_TYPE> <TLV_PAYLOAD>' allows sending specific TLV with arbitrary payloads.

Example:
`tlv send a 1234`
Send ping TLV(0x0a) with payload '1234'

The 'tlv' command tree is to gain the ability to send the TLV with any payload at any time.
This feature allows to check the behavior of TCAT device against:
- receiving of unexpected TLV
- receiving of TLV with corrupted payload
- receiving of TLVs sent in custom order
2025-01-08 10:49:32 -08:00
Jakub Uliarczyk 9ae7de563c [tcat] fix: use normalize_uuid_str() on BBTC_SERVICE_UUID (#10879)
This commit adds 'normalize_uuid_str()' in 'scan_tcat_devices()'.
It fixes an issue finding TCAT devices in newer versions of the 'bleak' module.
2024-11-21 09:04:28 -08:00
Przemysław Bida efa6f9fbc6 [tcat] implementation of tcat disconnect command (#10859)
Implementation of tcat disconnect command in python client.
2024-11-20 19:46:19 -08:00
Przemysław Bida bfcfc3f2b8 [tcat] add TCAT advertisement parsing in client (#10863)
Commit adds TCAT advertisement pars and display during scan operation
perormed in python client.
2024-11-20 18:49:28 -08:00
Jakub Uliarczyk 68c78d357e [tcat] feat: extend dataset hex command (#10831)
This commit extends the 'dataset hex' command in the bbtc.py script by
allowing dataset TLVs to be set using a hex-encoded format.

Till now the 'dataset hex' command was only printing the
'ThreadDataset' object values in hex-encoded format, there was no
functionality to set the TLVs using hex-encoded format.

The 'dataset hex' command has been modified so the user can pass
dataset TLVs in hex-encoded format as an argument to this
command. This enables the script to set desired dataset TLVs in one
command, instead of calling dataset commands individually.

Example usage: 'dataset hex <hex-encoded TLVs>'
2024-10-14 11:06:16 -07:00
Jakub Uliarczyk ed14eb19bd [tcat] feat: add dataset clear command (#10812)
Added 'clear' command to the 'dataset' command tree. This allows to
remove all entries in the 'ThreadDataset' object used by the script to
store the dataset values.

The reason behind this feature is that in the current implementation
of the script, the 'ThreadDataset' object entries are always
initialized by 'initial_dataset' when running the script.

No command allows to clear/remove the particular entry, which makes
this script unable to send an active dataset to the target device
without specific dataset values(custom dataset).

To make this possible, the 'clear' command has been added to the
'dataset' command tree, which removes all entries from the
'ThreadDataset' object and, by using existing commands, sets the
desired entries in the 'ThreadDataset' object from scratch.

This enables the script to send custom active dataset values to the
target device.
2024-10-10 21:48:26 -07:00
Jakub Uliarczyk 52d3f49ffe [tcat] feat: add 'adapter' argument and use 'BLEDevice' for scanning (#10657)
Added '-a', '--adapter' arguments to the bbtc.py arguments
parser. This allows the selection of the HCI adapter for the scanning
procedure.

According to 'Bleak' documentation of the 'BleakClient'
class(https://bleak.readthedocs.io/en/latest/api/client.html#bleakclient-class),
it's better to use the 'BLEDevice' object in 'BleakClient' during the
object instantiation, therefore it has been changed for the scanning
2024-10-07 08:55:20 -07:00
Przemysław Bida 213665cce0 [tcat] implementation of TCAT general class commands (#10700)
Commit introduces implementation of missing general class commands:
- PresentPskdHash
- PresentPskcHash
- PresentInstallCodeHash
- RequestRandomNumChallenge
- RequestPskdHash

Also include minor fixes in Tcat python client and refactoring of expect
tests for tcat.
2024-10-02 11:10:16 -07:00
Esko Dijk 4459c54069 [tcat][ble] fixes to connection state mgmt and Disconnect cmd (#10619)
- Fixes to connection state management and handling of Disconnect
  command TLV
  - specifically, this now ensures that TCAT remains on (started)
    after a commissioner disconnects. Earlier, there was the problem
    that the 2nd commissioner couldn't connect anymore.
  - specifically, in ble_secure.cpp the check for if
    (mTcatAgent.IsEnabled()) is removed, since the err =
    mTcatAgent.Connected(mTls) will already check this and raise an
    error if not enabled. If not enabled, the Device is in a wrong
    state to handle TCAT Commissioner commands so now it closes the
    connection right away. That's better than to leave the
    Commissioner in limbo on the TLS connection. The Commissioner can
    now retry again and all will be well again.
- timeout of at most 10 seconds on UDP write operation in simulation
  mode (if longer, the TCAT device isn't reachable and the
  Commissioner now shows the error to the user.) Earlier, it got stuck
  forever.
- Corrects some copy/paste errors in API definitions in comments; adds
  comments where needed to explain.
  - adds whitespace at some places to align format with rest of code
- improved some of the --debug output for the UDP simulation mode of
  the TCAT Commissioner.
2024-09-05 19:59:39 -07:00
Przemyslaw Bida db6393251a [tcat] Add timeout while connecting over BLE. (#10597)
Adding timeout while handling ble connection establishement in TCAT.
2024-09-04 07:49:33 -07:00
Przemyslaw Bida 12cf1207d2 [tcat] Fix handling certificate path in tcat client. (#10597)
Commit fixes propagation of certificate path from `cert-path` option
to `scan` command.
2024-09-04 07:49:33 -07:00
Przemysław Bida 8a0ea2b692 [tcat] implement new tcat General commands (#10526)
New General TLV's implemented:
- Get network name
- Get device id
- Get ext pan ID
- get provisioning URL
2024-08-21 19:21:10 -07:00
Przemysław Bida bf5ddb908e [tcat] implementation of tcat Ping command (#10484)
Commit implements Tcat ping command `kTlvPing`.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-07-09 10:11:39 -07:00
Przemysław Bida 6aa6f45606 [tcat] implement decommissioning in tcat_agent (#10415)
Commits adds handling of TCAT TLV 0x60 `kTlvDecommission`.
2024-07-01 19:14:53 -07:00
Esko Dijk 3873c6fcd5 [tcat] add TCAT Commissioner / Device certs for Thread certification testing (#10211) 2024-06-06 11:27:44 -07:00
Przemysław Bida 3ae275f1ac [simulation] add simulation tests framework for tcat (#9724)
This commit adds simulation framework for tcat based on posix udp
sockets.
2024-03-22 10:30:59 -07:00
Maciej Baczmański 33574ad417 [tools] add missing tcat ble client files (#9857)
Some files were missing during repo migration, this commit adds them.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
Co-authored-by: Piotr Jasinski <piotr.jasinski990@gmail.com>
Co-authored-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-02-16 11:12:57 -08:00
Piotr Jasinski 905a22e0c7 [tools] add tcat ble client (#9739)
Adds TCAT client implementation for BLE transport.

Signed-off-by: Piotr Jasinski <piotr.jasinski990@gmail.com>
Co-authored-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2024-02-07 13:13:12 -08:00