Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] THP #4050

Draft
wants to merge 110 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
b2cbe80
build(ci): add thp builds and tests
M1nd3r Dec 2, 2024
5025292
feat(common): add thp protobuf definitions and modify pb2py
M1nd3r Dec 2, 2024
b46dcc7
chore(core): adapt emu.py to new trezorlib
M1nd3r Dec 2, 2024
3108f85
chore: add build_unix_frozen_debug to core Makefile
M1nd3r Dec 2, 2024
1f59eb6
chore(core): adapt SConscripts to THP needs
M1nd3r Dec 2, 2024
2b93d4a
feat(core): implement THP
M1nd3r Dec 2, 2024
d9d95c1
feat(legacy): adapt legacy to THP changes
M1nd3r Dec 2, 2024
a15616a
feat(python): implement session based trezorlib
M1nd3r Dec 2, 2024
a5cb6db
chore(python): add python requirements
M1nd3r Dec 2, 2024
1ea08fc
chore(python): update python tools
M1nd3r Dec 2, 2024
d2843c6
test: update click tests
M1nd3r Dec 2, 2024
6738e15
test: update persistence tests
M1nd3r Dec 2, 2024
763abdc
test: update upgrade tests
M1nd3r Dec 2, 2024
f036e40
test: update ui tests
M1nd3r Dec 2, 2024
c3d3fa5
test: update device tests
M1nd3r Dec 2, 2024
71fad99
chore(vendor): update fido2-tests
M1nd3r Dec 2, 2024
279e0c3
refactor(core): improve readability of channel_manager
M1nd3r Dec 3, 2024
e46950d
refactor(core): improve readability and logging in channel.py
M1nd3r Dec 3, 2024
4fd8636
refactor(core): clean channel and received_message_handler
M1nd3r Dec 4, 2024
1baa858
refactor(core): move exclude list from wipe to wipe_cache
M1nd3r Dec 4, 2024
4a43445
fixup! build(ci): add thp builds and tests
M1nd3r Dec 4, 2024
9e87ac8
refactor(python,tests): add is_invalidated flag to client, do not set…
M1nd3r Dec 4, 2024
7b837be
fix(tests): change xfail to skip when using protocol_marker
M1nd3r Dec 4, 2024
66be71c
refactor(common): remove pairing_in/out and channel_in/out proto options
M1nd3r Dec 4, 2024
2ef8d15
refactor(core): move wire buffer handling completely to memory_manager
M1nd3r Dec 4, 2024
c27ba1b
refactor(core): move handling of ThpCreateNewSession message into bas…
M1nd3r Dec 4, 2024
aa79443
wip
M1nd3r Dec 4, 2024
c059a67
fixup! build(ci): add thp builds and tests
M1nd3r Dec 4, 2024
c4d5979
fixup! feat(core): implement THP
M1nd3r Dec 4, 2024
d7f0cae
feat(python): add lock() to TrezorClientDebugLink
M1nd3r Dec 5, 2024
ed2d196
chore: update fixtures for T2T1
M1nd3r Dec 5, 2024
377c93c
fix(tests): unlock device when getting a new session
M1nd3r Dec 5, 2024
8b8bef3
chore(tests): start screen recording only after the session fixture h…
M1nd3r Dec 5, 2024
d452fd1
fixup! chore: update fixtures for T2T1
M1nd3r Dec 5, 2024
17f54a6
fixup! fixup! chore: update fixtures for T2T1
M1nd3r Dec 5, 2024
741af09
wip
M1nd3r Dec 6, 2024
5896ce6
wip - change session behavior
M1nd3r Dec 9, 2024
48a723e
fixup! wip - change session behavior [no changelog]
M1nd3r Dec 9, 2024
b1ab821
fixup! fixup! wip - change session behavior [no changelog]
M1nd3r Dec 9, 2024
cdfedba
test: fix device test test_authorize_coinjoin
M1nd3r Dec 9, 2024
f4ca92e
wip buffer locking-
M1nd3r Dec 11, 2024
c3d5362
fix: return InvalidSessionError when trying to access cache of Seedle…
M1nd3r Dec 12, 2024
d2ef300
wip: single packet decryption (not finished)
M1nd3r Dec 13, 2024
9ad08ce
fixup! wip: single packet decryption (not finished) [no changelog]
M1nd3r Dec 18, 2024
70c3434
fixup! fixup! wip: single packet decryption (not finished) [no change…
M1nd3r Dec 18, 2024
4b0f4ff
chore(core): make wipe device proceed even if sending of success mess…
M1nd3r Dec 19, 2024
bf7ffd7
fixup! fixup! fixup! wip: single packet decryption (not finished) [no…
M1nd3r Dec 19, 2024
5f1f0d7
chore(core): remove management session code from handle_ThpCreateNewS…
M1nd3r Dec 19, 2024
0cd191d
chore(core): remove TODO comment from received_message_handler
M1nd3r Dec 19, 2024
cf99bef
chore: fix incomplete enum change
M1nd3r Dec 19, 2024
bab44e6
WIP: try simplify message handler, might break something
M1nd3r Dec 19, 2024
e2d3c1c
fixup! fixup! fixup! fixup! wip: single packet decryption (not finish…
M1nd3r Dec 19, 2024
7867e7d
fixup! fixup! fixup! fixup! fixup! wip: single packet decryption (not…
M1nd3r Dec 19, 2024
7e81ae2
fix style after rebase
M1nd3r Dec 20, 2024
f006559
chore(python): add session_context to cli to handle exceptions gracef…
M1nd3r Dec 20, 2024
0cfe6b5
try fix legacy build
M1nd3r Dec 20, 2024
9ddc28e
fix(core): modify python test, ignore broken THP test
M1nd3r Dec 21, 2024
ed52487
fix(test): update slip39 backup device test
M1nd3r Dec 30, 2024
7556031
fix: remove unnecessary comment
M1nd3r Dec 30, 2024
f690e0f
fix device tests
M1nd3r Jan 2, 2025
f938dd3
fix(core): update comments, refactor debug log in session context
M1nd3r Jan 6, 2025
38f536b
fix: fix change failed test cause
M1nd3r Jan 8, 2025
6687b10
fix(test): fix style in thp unit tests
M1nd3r Jan 8, 2025
21fd54e
fix(core): remove unused payload parameter in channel
M1nd3r Jan 8, 2025
c790c8f
temp: fix device tests test_protection_levels by removing session.end…
M1nd3r Jan 8, 2025
b4aafbe
chore(core): fix channel manager docs
M1nd3r Jan 9, 2025
9676502
feat(core): send UNALLOCATED_CHANNEL error as a response only on init…
M1nd3r Jan 13, 2025
2d3bf0e
fix(core): fix cardano session derivation
M1nd3r Jan 23, 2025
f6e13fa
test: fix device test enable_labeling
M1nd3r Jan 23, 2025
698b742
test: fix device test for entropy checks
M1nd3r Jan 23, 2025
e404806
test: fix device test for slip39 advanced backup
M1nd3r Jan 23, 2025
d2d8b82
tests: fix device tests for codecV1
M1nd3r Jan 24, 2025
2f7426b
chore(python): remove outdated fix for MOCK_URANDOM problems
M1nd3r Jan 24, 2025
9a2b8c3
fix(core): update packet length handling
M1nd3r Jan 24, 2025
ae08b64
test: skip thp device test on protocol_v1 emu
M1nd3r Jan 24, 2025
150fff9
chore: update fixtures
M1nd3r Jan 24, 2025
8ec5648
fixup! test: skip thp device test on protocol_v1 emu [no changelog]
M1nd3r Jan 24, 2025
ca6a9e9
fix: gen
M1nd3r Jan 24, 2025
770180a
test(core): fix thp unit tests
M1nd3r Jan 24, 2025
ccf397b
style: fix yaml core
M1nd3r Jan 24, 2025
b506e6d
refactor(python): improve structure of protocol_v2 channel establishment
M1nd3r Jan 25, 2025
0531105
test: add thp device tests
M1nd3r Jan 27, 2025
027822b
temp: update pairing process, part 1
M1nd3r Jan 27, 2025
e3bec99
tests(python): improve thp device tests
M1nd3r Jan 29, 2025
b0b40ab
fix(legacy): fix protobuf options broken after renaming nfc_unidirect…
M1nd3r Jan 29, 2025
7a8f327
fix: (temporary) disable failing thp unit tests
M1nd3r Jan 30, 2025
f7b876c
fixup! chore(vendor): update fido2-tests [no changelog]
M1nd3r Jan 30, 2025
a7422cb
chore: add DebugLinkPairingInfo
M1nd3r Jan 30, 2025
265a909
feat(core, python): implement nfc pairing for tests, add device test
M1nd3r Jan 30, 2025
77ecf52
chore: update fixtures
M1nd3r Jan 30, 2025
1493f67
feat(python): add elligator2
M1nd3r Jan 30, 2025
583e29d
feat(core, python): implement new code entry pairing
M1nd3r Jan 30, 2025
d50ec53
refactor(python): improve protocolV2 and related tests
M1nd3r Jan 30, 2025
7c154f4
feat(core, python): implement autoconnect credentials and add test
M1nd3r Jan 31, 2025
8a39d29
fixup! feat(core, python): implement autoconnect credentials and add …
M1nd3r Jan 31, 2025
9b6890f
chore(python): add handshake hash to channelData
M1nd3r Jan 31, 2025
3a36648
chore: remove unnecessary changes
M1nd3r Jan 31, 2025
8cf667f
chore(core): allow SkipPairing only on debug
M1nd3r Jan 31, 2025
c25f5c1
refactor: improve structure of code for showing pairing screens and s…
M1nd3r Jan 31, 2025
b5084c7
fix(test): comment out outdated code in already broken test
M1nd3r Jan 31, 2025
a93b01c
chore: minor fixes in style and reducing unnecessary diffs with main
M1nd3r Jan 31, 2025
5f85a2f
fix(tests): fix screen recording for persistance tests on THP builds
M1nd3r Feb 3, 2025
501864a
chore(python): get human-readable errors for all ThpErrorType-s in tr…
M1nd3r Feb 3, 2025
f0c630c
fixup! fix(tests): fix screen recording for persistance tests on THP …
M1nd3r Feb 3, 2025
cb8b0e2
fix(tests): style in translations.py
M1nd3r Feb 3, 2025
b8982f5
chore(core): remove deprecated methods from cache_thp
M1nd3r Feb 3, 2025
7af9e0d
chore: remove management session remnants
M1nd3r Feb 3, 2025
4a89665
fixup! chore(python): get human-readable errors for all ThpErrorType-…
M1nd3r Feb 3, 2025
f0f9a78
persistence UI fix
mmilata Feb 4, 2025
47cbe36
chore: rename management_session to seedless_session everywhere
M1nd3r Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
142 changes: 111 additions & 31 deletions .github/workflows/core.yml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions common/protob/messages-common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ message Failure {
Failure_PinMismatch = 12;
Failure_WipeCodeMismatch = 13;
Failure_InvalidSession = 14;
Failure_ThpUnallocatedSession = 15;
Failure_InvalidProtocol = 16;
Failure_BufferError = 17;
Failure_DeviceIsBusy = 18;
Failure_FirmwareError = 99;
}
}
Expand Down
25 changes: 24 additions & 1 deletion common/protob/messages-debug.proto
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ message DebugLinkRecordScreen {
}

/**
* Request: Computer asks for device state
* Request: Host asks for device state
* @start
* @next DebugLinkState
*/
Expand Down Expand Up @@ -132,6 +132,29 @@ message DebugLinkState {
repeated string tokens = 13; // current layout represented as a list of string tokens
}

/**
* Request: Host asks for device pairing info
* @start
* @next DebugLinkPairingInfo
*/
message DebugLinkGetPairingInfo {
optional bytes channel_id = 1; // ID of the THP channel to get pairing info from
optional bytes handshake_hash = 2; // handshake hash of the THP channel
optional bytes nfc_secret_host = 3; // host's NFC secret (In case of NFC pairing)
}

/**
* Response: Device pairing info
* @end
*/
message DebugLinkPairingInfo {
optional bytes channel_id = 1; // ID of the THP channel the pairing info is from
optional bytes handshake_hash = 2; // handshake hash of the THP channel
optional uint32 code_entry_code = 3; // CodeEntry pairing code
optional bytes code_qr_code = 4; // QrCode pairing code
optional bytes nfc_secret_trezor = 5; // NFC secret used in NFC pairing
}

/**
* Request: Ask device to restart
* @start
Expand Down
219 changes: 219 additions & 0 deletions common/protob/messages-thp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,232 @@ import "options.proto";

option (include_in_bitcoin_only) = true;

/**
* Mapping between Trezor wire identifier (uint) and a Thp protobuf message
*/
enum ThpMessageType {
reserved 0 to 999; // Values reserved by other messages, see messages.proto

ThpMessageType_ThpCreateNewSession = 1000 [(bitcoin_only)=true];
ThpMessageType_ThpPairingRequest = 1006 [(bitcoin_only) = true];
ThpMessageType_ThpPairingRequestApproved = 1007 [(bitcoin_only) = true];
ThpMessageType_ThpSelectMethod = 1008 [(bitcoin_only) = true];
ThpMessageType_ThpPairingPreparationsFinished = 1009 [(bitcoin_only) = true];
ThpMessageType_ThpCredentialRequest = 1010 [(bitcoin_only) = true];
ThpMessageType_ThpCredentialResponse = 1011 [(bitcoin_only) = true];
ThpMessageType_ThpEndRequest = 1012 [(bitcoin_only) = true];
ThpMessageType_ThpEndResponse = 1013 [(bitcoin_only) = true];
ThpMessageType_ThpCodeEntryCommitment = 1016 [(bitcoin_only)=true];
ThpMessageType_ThpCodeEntryChallenge = 1017 [(bitcoin_only)=true];
ThpMessageType_ThpCodeEntryCpaceTrezor = 1018 [(bitcoin_only)=true];
ThpMessageType_ThpCodeEntryCpaceHostTag = 1019 [(bitcoin_only)=true];
ThpMessageType_ThpCodeEntrySecret = 1020 [(bitcoin_only)=true];
ThpMessageType_ThpQrCodeTag = 1024 [(bitcoin_only)=true];
ThpMessageType_ThpQrCodeSecret = 1025 [(bitcoin_only)=true];
ThpMessageType_ThpNfcTagHost = 1032 [(bitcoin_only)=true];
ThpMessageType_ThpNfcTagTrezor = 1033 [(bitcoin_only)=true];

reserved 1100 to 2147483647; // Values reserved by other messages, see messages.proto
}


/**
* Numeric identifiers of pairing methods.
* @embed
*/
enum ThpPairingMethod {
SkipPairing = 1; // Trust without MITM protection.
CodeEntry = 2; // User types code diplayed on Trezor into the host application.
QrCode = 3; // User scans code displayed on Trezor into host application.
NFC = 4; // Trezor and host application exchange authentication secrets via NFC.
}

/**
* @embed
*/
message ThpDeviceProperties {
optional string internal_model = 1; // Internal model name e.g. "T2B1".
optional uint32 model_variant = 2; // Encodes the device properties such as color.
optional uint32 protocol_version_major = 3; // The major version of the communication protocol used by the firmware.
optional uint32 protocol_version_minor = 4; // The minor version of the communication protocol used by the firmware.
repeated ThpPairingMethod pairing_methods = 5; // The pairing methods supported by the Trezor.
}

/**
* @embed
*/
message ThpHandshakeCompletionReqNoisePayload {
optional bytes host_pairing_credential = 1; // Host's pairing credential
}

/**
* Request: Ask device for a new session with given passphrase.
* @start
* @next Success
*/
message ThpCreateNewSession{
optional string passphrase = 1;
optional bool on_device = 2; // User wants to enter passphrase on the device
optional bool derive_cardano = 3; // If True, Cardano keys will be derived. Ignored with BTC-only
}


/**
* Request: Start pairing process.
* @start
* @next ThpPairingRequestApproved
*/
message ThpPairingRequest{
optional string host_name = 1; // Human-readable host name
}

/**
* Response: Host is allowed to start pairing process.
* @start
* @next ThpSelectMethod
*/
message ThpPairingRequestApproved{
}

/**
* Request: Start pairing using the method selected.
* @start
* @next ThpPairingPreparationsFinished
* @next ThpCodeEntryCommitment
*/
message ThpSelectMethod {
optional ThpPairingMethod selected_pairing_method = 1;
}

/**
* Response: Pairing is ready for user input / OOB communication.
* @next ThpCodeEntryCpace
* @next ThpQrCodeTag
* @next ThpNfcTagHost
*/
message ThpPairingPreparationsFinished{
}

/**
* Response: If Code Entry is an allowed pairing option, Trezor responds with a commitment.
* @next ThpCodeEntryChallenge
*/
message ThpCodeEntryCommitment {
optional bytes commitment = 1; // SHA-256 of Trezor's random 32-byte secret
}

/**
* Response: Host responds to Trezor's Code Entry commitment with a challenge.
* @next ThpCodeEntryCpaceTrezor
*/
message ThpCodeEntryChallenge {
optional bytes challenge = 1; // Host's random 32-byte challenge
}



/**
* Response: Trezor continues with the CPACE protocol.
* @next ThpCodeEntryCpaceHostTag
*/
message ThpCodeEntryCpaceTrezor {
optional bytes cpace_trezor_public_key = 1; // Trezor's ephemeral CPace public key
}

/**
* Request: User selected Code Entry option in Host. Host starts CPACE protocol with Trezor.
* @next ThpCodeEntrySecret
*/
message ThpCodeEntryCpaceHostTag {
optional bytes cpace_host_public_key = 1; // Host's ephemeral CPace public key
optional bytes tag = 2; // SHA-256 of shared secret

}

/**
* Response: Trezor finishes the CPACE protocol.
* @next ThpCredentialRequest
* @next ThpEndRequest
*/
message ThpCodeEntrySecret {
optional bytes secret = 1; // Trezor's secret
}

/**
* Request: User selected QR Code pairing option. Host sends a QR Tag.
* @next ThpQrCodeSecret
*/
message ThpQrCodeTag {
optional bytes tag = 1; // SHA-256 of shared secret
}

/**
* Response: Trezor sends the QR secret.
* @next ThpCredentialRequest
* @next ThpEndRequest
*/
message ThpQrCodeSecret {
optional bytes secret = 1; // Trezor's secret
}

/**
* Request: User selected Unidirectional NFC pairing option. Host sends an Unidirectional NFC Tag.
* @next ThpNfcTagTrezor
*/
message ThpNfcTagHost {
optional bytes tag = 1; // Host's tag
}

/**
* Response: Trezor sends the Unidirectioal NFC secret.
* @next ThpCredentialRequest
* @next ThpEndRequest
*/
message ThpNfcTagTrezor {
optional bytes tag = 1; // Trezor's tag
}

/**
* Request: Host requests issuance of a new pairing credential.
* @start
* @next ThpCredentialResponse
*/
message ThpCredentialRequest {
optional bytes host_static_pubkey = 1; // Host's static public key used in the handshake.
optional bool autoconnect = 2; // Whether host wants to autoconnect without user confirmation
}

/**
* Response: Trezor issues a new pairing credential.
* @next ThpCredentialRequest
* @next ThpEndRequest
*/
message ThpCredentialResponse {
optional bytes trezor_static_pubkey = 1; // Trezor's static public key used in the handshake.
optional bytes credential = 2; // The pairing credential issued by the Trezor to the host.
}

/**
* Request: Host requests transition to the encrypted traffic phase.
* @start
* @next ThpEndResponse
*/
message ThpEndRequest {}

/**
* Response: Trezor approves transition to the encrypted traffic phase
* @end
*/
message ThpEndResponse {}

/**
* Only for internal use.
* @embed
*/
message ThpCredentialMetadata {
option (internal_only) = true;
optional string host_name = 1; // Human-readable host name
optional bool autoconnect = 2; // Whether host is allowed to autoconnect without user confirmation
}

/**
Expand Down
2 changes: 2 additions & 0 deletions common/protob/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ enum MessageType {
MessageType_DebugLinkWatchLayout = 9006 [(bitcoin_only) = true, (wire_debug_in) = true];
MessageType_DebugLinkResetDebugEvents = 9007 [(bitcoin_only) = true, (wire_debug_in) = true];
MessageType_DebugLinkOptigaSetSecMax = 9008 [(bitcoin_only) = true, (wire_debug_in) = true];
MessageType_DebugLinkGetPairingInfo = 9009 [(bitcoin_only) = true, (wire_debug_in) = true];
MessageType_DebugLinkPairingInfo = 9010 [(bitcoin_only) = true, (wire_debug_out) = true];

// Ethereum
MessageType_EthereumGetPublicKey = 450 [(wire_in) = true];
Expand Down
15 changes: 14 additions & 1 deletion common/protob/pb2py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ INT_TYPES = (
)

MESSAGE_TYPE_ENUM = "MessageType"
THP_MESSAGE_TYPE_ENUM = "ThpMessageType"

LengthDelimited = c.Struct(
"len" / c.VarInt,
Expand Down Expand Up @@ -239,6 +240,9 @@ class ProtoMessage:
@classmethod
def from_message(cls, descriptor: "Descriptor", message):
message_type = find_by_name(descriptor.message_type_enum.value, message.name)
thp_message_type = None
if not isinstance(descriptor.thp_message_type_enum,tuple):
thp_message_type = find_by_name(descriptor.thp_message_type_enum.value, message.name)
# use extensions set on the message_type entry (if any)
extensions = descriptor.get_extensions(message_type)
# override with extensions set on the message itself
Expand All @@ -248,6 +252,8 @@ class ProtoMessage:
wire_type = extensions["wire_type"]
elif message_type is not None:
wire_type = message_type.number
elif thp_message_type is not None:
wire_type = thp_message_type.number
else:
wire_type = None

Expand Down Expand Up @@ -351,10 +357,13 @@ class Descriptor:
]
logging.debug(f"found {len(self.files)} bitcoin-only files")

# find message_type enum
# find message_type and thp_message_type enum
top_level_enums = itertools.chain.from_iterable(f.enum_type for f in self.files)
self.message_type_enum = find_by_name(top_level_enums, MESSAGE_TYPE_ENUM, ())
top_level_enums = itertools.chain.from_iterable(f.enum_type for f in self.files)
self.thp_message_type_enum = find_by_name(top_level_enums, THP_MESSAGE_TYPE_ENUM, ())
self.convert_enum_value_names(self.message_type_enum)
self.convert_enum_value_names(self.thp_message_type_enum)

# find messages and enums
self.messages = []
Expand Down Expand Up @@ -423,6 +432,8 @@ class Descriptor:
self._nested_types_from_message(nested.orig)

def convert_enum_value_names(self, enum):
if isinstance(enum,tuple):
return
for value in enum.value:
value.name = strip_enum_prefix(enum.name, value.name)

Expand Down Expand Up @@ -558,6 +569,8 @@ class RustBlobRenderer:
enums = []
cursor = 0
for enum in sorted(self.descriptor.enums, key=lambda e: e.name):
if enum.name == "MessageType":
continue
self.enum_map[enum.name] = cursor
enum_blob = ENUM_ENTRY.build(sorted(v.number for v in enum.value))
enums.append(enum_blob)
Expand Down
4 changes: 4 additions & 0 deletions core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ build_unix: templates ## build unix port
build_unix_frozen: templates build_cross ## build unix port with frozen modules
$(SCONS) $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_EMULATOR_FROZEN=1

build_unix_frozen_debug: templates build_cross ## build unix port with frozen modules and DEBUG (PYOPT="0")
$(SCONS) $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) TREZOR_EMULATOR_FROZEN=1 \
PYOPT=0

build_unix_debug: templates ## build unix port
$(SCONS) --max-drift=1 $(UNIX_BUILD_DIR)/trezor-emu-core $(UNIX_PORT_OPTS) \
TREZOR_EMULATOR_ASAN=1 TREZOR_EMULATOR_DEBUGGABLE=1
Expand Down
21 changes: 15 additions & 6 deletions core/SConscript.firmware
Original file line number Diff line number Diff line change
Expand Up @@ -578,14 +578,23 @@ if FROZEN:
] if not EVERYTHING else []
))

if THP:
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/thp/*.py'))
if not THP or PYOPT == '0':
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/codec/*.py'))

SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/*.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/wire/codec/*.py'))

SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py',
exclude=[
SOURCE_PY_DIR + 'storage/sd_salt.py',
] if not SDCARD else []
))

exclude_list = []
if 'sd_card' not in FEATURES_AVAILABLE:
exclude_list.append(SOURCE_PY_DIR + 'storage/sd_salt.py')
if THP and PYOPT == '1':
exclude_list.append(SOURCE_PY_DIR + 'storage/cache_codec.py')
if not THP:
exclude_list.append(SOURCE_PY_DIR + 'storage/cache_thp.py')

SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'storage/*.py', exclude=exclude_list))

SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/messages/__init__.py'))
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'trezor/enums/*.py',
Expand Down
Loading
Loading