Commit Graph

421 Commits

Author SHA1 Message Date
Roman Zeyde
456ea7d5d6 feat(core+python): support device unlocking during THP handshake
Add a flag to the first THP handshake message, so the device can:

- fail the handshake if the device is locked (current behavior)
- prompt the user to enter the PIN (similar to other non-pairing flows)

NOTE: This is a backward-incompatible change, so Suite THP implementation MUST be adapted as well.

Co-authored-by: M1nd3r <petrsedlacek.km@seznam.cz>
2025-10-06 11:20:33 +02:00
Roman Zeyde
5bab202950 chore(core): make host_name & app_name required also in ThpCredentialMetadata
[no changelog]
2025-09-25 18:27:11 +03:00
Roman Zeyde
b9411a6bc1 chore(core): move paired_cache to trezor.wire.thp
Also, log `ThpPairedCache`-related events.

[no changelog]
2025-09-25 18:27:11 +03:00
Lukas Bielesch
a80a1d0045 feat(core/eckhart): cache THP app/host name along with MAC
[no changelog]

Co-authored-by: Martin Milata <martin@martinmilata.cz>
2025-09-21 21:55:50 +02:00
Andrew Kozlik
41cd4bbfcf feat(core): Use correct pairing keys in Tropic handshake. 2025-09-18 18:37:58 +02:00
Andrew Kozlik
37b0c3684f refactor(core): Move Tropic constants to tropic.h.
[no changelog]
2025-09-18 18:37:58 +02:00
Roman Zeyde
2260cf4e2f feat(core): allow caching recent THP paired hostnames and MAC addresses
Only entries with bonded MAC addresses will be stored.

[no changelog]
2025-09-11 15:07:36 +03:00
Roman Zeyde
49f4537355 feat(core): trim strings to specific bytes' limit
[no changelog]
2025-09-10 18:17:06 +03:00
M1nd3r
60cc5c0640 refactor(core): replace all Union usage by | syntax in core except core/vendor
[no changelog]
2025-09-09 12:09:47 +02:00
matejcik
87f5f12d64 style: update to black 25 style, silence new flake8 warnings
[no changelog]
2025-09-08 16:27:44 +02:00
Roman Zeyde
50b57d6ce3 feat(core): allow preempting stale THP channels on all interfaces
Instead of running 2 separate THP session handling tasks
(on USB & BLE interfaces), this PR uses a single task, which
will handle both - in order to allow preempting the event loop
in case there is an unresponsive channel.

`ThpContext` is split into interface-specific class (`InterfaceContext`)
and a "global" THP receiver (`ThpContext`).

Also, removing `core/tests/test_trezor.wire.thp.py` - to be reimplemented in a following PR.

[no changelog]
2025-08-29 21:02:59 +03:00
Roman Zeyde
c320020822 feat(core): reimplement THP event loop restarts
[no changelog]
2025-08-21 14:46:02 +03:00
Ondřej Vejpustek
b7f2e6f5f4 feat(core): remove tropic.get_certificate()
[no changelog]
2025-08-18 15:06:47 +02:00
Roman Zeyde
e1b56022da refactor(core): simplify THP write-related code
- move fragmentation code into `PacketHeader.fragment_payload()`
- use `ThpContext.write_payload()` to send responses to the host
- precompute `INIT_HEADER_LENGTH` and `CONT_HEADER_LENGTH`
- remove most of `trezor.write.thp.writer` code

[no changelog]
2025-08-12 11:49:25 +03:00
Roman Zeyde
697c3a54c6 chore(core): export memzero() via trezor.utils
[no changelog]
2025-08-12 11:49:25 +03:00
Roman Zeyde
18db6c9478 refactor(core): introduce ThpContext
This PR moves `thp_main` code to a "context"-like class, similar to
`CodecContext` for Protocol v1.

It encapsulates payload reassembly, as well as handling and responding
to low-level single packet THP messages.

Also, channel cache is now using interface number for `CHANNEL_IFACE`,
in order to simplify channel interface serialization.

[no changelog]
2025-08-12 08:12:47 +03:00
Roman Zeyde
8b06fdacad chore(core): fix a small typo in thp_common.py
Also, use `log._min_level` to suppress debug logging.

[no changelog]
2025-08-12 08:12:47 +03:00
Roman Zeyde
f1c08bcfe3 chore(core): reduce default value in MockHID c-tor
It would allow to use it as `CHANNEL_IFACE` (in a following commit).

[no changelog]
2025-08-12 08:12:47 +03:00
tychovrahe
74c3deaf27 refactor(core): rewrite debug overlay in rust
[no changelog]
2025-08-11 16:41:35 +02:00
Lukas Bielesch
6e2d44d765 chore(core): use non-breakable space between value and unit 2025-08-06 14:19:34 +02:00
M1nd3r
07f92d796e test(core): add THP unit tests 2025-07-31 20:29:05 +02:00
M1nd3r
3ce1939c64 test(core): adjust existing unit tests to THP 2025-07-31 20:29:05 +02:00
cepetr
ba908a5eb6 feat(core): update t3w1 memory layout
[no changelog]
2025-07-29 11:37:47 +02:00
M1nd3r
0b2fdf3667 chore(common/core): use public_key instead of pubkey in THP messages
[no changelog]
2025-07-21 13:05:51 +02:00
M1nd3r
be287648d0 chore(core, tests): add MockAsync and await_result_patched
[no changelog]
2025-07-11 15:36:51 +02:00
Andrew Kozlik
cd1b194be8 feat(core): Include address_n in address MAC. 2025-07-10 10:10:14 +02:00
M1nd3r
df28c84e0b chore(storage): rename DEVICE_SECRET and CRED_AUTH_KEY_COUNTER
[no changelog]
2025-05-19 13:33:17 +02:00
Roman Zeyde
3a7850f6a0 chore: remove BNB Beacon Chain support 2025-05-13 09:04:48 +03:00
matejcik
ff1c9b9f9a tests(core): run make test headless
don't spam the emulator window ^_^
2025-04-29 14:54:41 +02:00
matejcik
f10588b2b6 tests(core): split up definition unit tests and add Solana cross-parseability check 2025-04-29 14:54:41 +02:00
matejcik
e4e6d60e64 refactor(core/solana): restructure programs.json and related code 2025-04-29 14:54:41 +02:00
Eugene Rossokha
ffbdea202a feat(core): add loadable solana tokens 2025-04-29 14:54:41 +02:00
Roman Zeyde
ad73e41080 feat(core): support USB/BLE sessions
All interfaces are sharing a single 8kB buffer.
It is reallocated once per session and is acquired by the first active session.
Other concurrent sessions will respond with an "Another session in progress" error.

[no changelog]
2025-03-31 13:20:53 +03:00
Ioan Bizău
c9c543443d feat(core/tests): add smoke test for libtropic
[no changelog]
2025-03-13 15:08:48 +01:00
Martin Milata
bb5972b7e2 test(core): update monero tests binary
[no changelog]
2025-02-05 16:25:53 +01:00
tychovrahe
69a61e98e0 feat(core): adjust codec_v1 to work with differently sized RX and TX packets
[no changelog]
2025-01-23 16:46:12 +01:00
tychovrahe
5fd773757c fix(core): fix fading issues 2025-01-23 15:24:00 +01:00
tychovrahe
e4f4985584 refactor(core): split polling can_read and reading from USB
[no changelog]
2025-01-13 17:42:30 +01:00
Martin Milata
dadff32f39 build(core): use internal model names everywhere
TREZOR_MODEL=T and TREZOR_MODEL=R

no longer work, please use

  TREZOR_MODEL=T2T1 and TREZOR_MODEL=T2B1

[no changelog]
2025-01-13 16:24:35 +01:00
tychovrahe
c26d9f4227 chore(core): increase size of assets area for U5G models
[no changelog]
2025-01-02 11:42:00 +01:00
Ondřej Vejpustek
8bf23696e1 style(core/tests): apply formatting
[no changelog]
2024-12-06 16:14:54 +01:00
Ondřej Vejpustek
97b2e6c751 style(core/tests): fix warnings
[no changelog]
2024-12-06 16:14:54 +01:00
Ondřej Vejpustek
345eaf79f9 style(core/tests): silent star import warnings
[no changelog]
2024-12-06 16:14:54 +01:00
M1nd3r
2eab963862 test(core): replace __init__ in unit tests with setUpClass and tearDownClass
[no changelog]
2024-12-02 12:39:15 +01:00
M1nd3r
22a7ba7070 test(core): add setUpClass and tearDownClass to core unit tests
[no changelog]
2024-12-02 12:39:15 +01:00
M1nd3r
a3c275f19a test(core): update tests to reflect cache refactor
[no changelog]
2024-12-02 12:39:15 +01:00
Ondřej Vejpustek
4dce3d0099 feat(core):: support sortedmulti 2024-12-02 12:21:24 +01:00
Ondřej Vejpustek
0a9c4ba4ec feat(core)): forbid multisig to singlesig change outputs 2024-12-02 12:21:24 +01:00
Ondřej Vejpustek
d8c15837cb test(core): add unit tests for ChangeDetector 2024-12-02 12:21:24 +01:00
tychovrahe
7998ae1463 feat(tests): adjust firmware hash calc test to expect different hashes based on model
[no changelog]
2024-11-14 09:30:20 +01:00