diff --git a/common/protob/messages-debug.proto b/common/protob/messages-debug.proto index e23cca159..148c01369 100644 --- a/common/protob/messages-debug.proto +++ b/common/protob/messages-debug.proto @@ -133,7 +133,8 @@ message DebugLinkState { optional management.BackupType mnemonic_type = 12; // current mnemonic type (BIP-39/SLIP-39) repeated string tokens = 13; // current layout represented as a list of string tokens optional uint32 thp_pairing_code_entry_code = 14; - optional bytes thp_pairing_secret = 15; + optional bytes thp_pairing_code_qr_code = 15; + optional bytes thp_pairing_code_nfc_unidirectional = 16; } /** diff --git a/core/src/apps/debug/__init__.py b/core/src/apps/debug/__init__.py index 382411e9b..d6a99d7fe 100644 --- a/core/src/apps/debug/__init__.py +++ b/core/src/apps/debug/__init__.py @@ -255,8 +255,9 @@ if __debug__: # just updated itself. The update is already live for the caller to retrieve. def _state( - thp_pairing_secret: bytes | None = None, thp_pairing_code_entry_code: int | None = None, + thp_pairing_code_qr_code: bytes | None = None, + thp_pairing_code_nfc_unidirectional: bytes | None = None, ) -> DebugLinkState: from trezor.messages import DebugLinkState @@ -277,15 +278,17 @@ if __debug__: reset_entropy=storage.reset_internal_entropy, tokens=tokens, thp_pairing_code_entry_code=thp_pairing_code_entry_code, - thp_pairing_secret=thp_pairing_secret, + thp_pairing_code_qr_code=thp_pairing_code_qr_code, + thp_pairing_code_nfc_unidirectional=thp_pairing_code_nfc_unidirectional, ) async def dispatch_DebugLinkGetState( msg: DebugLinkGetState, ) -> DebugLinkState | None: - thp_pairing_secret: bytes | None = None thp_pairing_code_entry_code: int | None = None + thp_pairing_code_qr_code: bytes | None = None + thp_pairing_code_nfc_unidirectional: bytes | None = None if utils.USE_THP and msg.thp_channel_id is not None: channel_id = int.from_bytes(msg.thp_channel_id, "big") @@ -301,11 +304,18 @@ if __debug__: except KeyError: pass if ctx is not None and isinstance(ctx, PairingContext): - thp_pairing_secret = ctx.secret thp_pairing_code_entry_code = ctx.display_data.code_code_entry + thp_pairing_code_qr_code = ctx.display_data.code_qr_code + thp_pairing_code_nfc_unidirectional = ( + ctx.display_data.code_nfc_unidirectional + ) if msg.wait_layout == DebugWaitType.IMMEDIATE: - return _state(thp_pairing_secret, thp_pairing_code_entry_code) + return _state( + thp_pairing_code_entry_code, + thp_pairing_code_qr_code, + thp_pairing_code_nfc_unidirectional, + ) assert DEBUG_CONTEXT is not None if msg.wait_layout == DebugWaitType.NEXT_LAYOUT: @@ -321,7 +331,11 @@ if __debug__: # We don't have a clear information that the layout is ready to "be read". return await return_layout_change(DEBUG_CONTEXT, detect_deadlock=True) else: - return _state(thp_pairing_secret, thp_pairing_code_entry_code) + return _state( + thp_pairing_code_entry_code, + thp_pairing_code_qr_code, + thp_pairing_code_nfc_unidirectional, + ) async def dispatch_DebugLinkRecordScreen(msg: DebugLinkRecordScreen) -> Success: if msg.target_directory: diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index a89c6c45b..764c157fe 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -2844,7 +2844,8 @@ if TYPE_CHECKING: mnemonic_type: "BackupType | None" tokens: "list[str]" thp_pairing_code_entry_code: "int | None" - thp_pairing_secret: "bytes | None" + thp_pairing_code_qr_code: "bytes | None" + thp_pairing_code_nfc_unidirectional: "bytes | None" def __init__( self, @@ -2863,7 +2864,8 @@ if TYPE_CHECKING: reset_word_pos: "int | None" = None, mnemonic_type: "BackupType | None" = None, thp_pairing_code_entry_code: "int | None" = None, - thp_pairing_secret: "bytes | None" = None, + thp_pairing_code_qr_code: "bytes | None" = None, + thp_pairing_code_nfc_unidirectional: "bytes | None" = None, ) -> None: pass diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 5c3d95161..daccc4c59 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -4095,7 +4095,8 @@ class DebugLinkState(protobuf.MessageType): 12: protobuf.Field("mnemonic_type", "BackupType", repeated=False, required=False, default=None), 13: protobuf.Field("tokens", "string", repeated=True, required=False, default=None), 14: protobuf.Field("thp_pairing_code_entry_code", "uint32", repeated=False, required=False, default=None), - 15: protobuf.Field("thp_pairing_secret", "bytes", repeated=False, required=False, default=None), + 15: protobuf.Field("thp_pairing_code_qr_code", "bytes", repeated=False, required=False, default=None), + 16: protobuf.Field("thp_pairing_code_nfc_unidirectional", "bytes", repeated=False, required=False, default=None), } def __init__( @@ -4115,7 +4116,8 @@ class DebugLinkState(protobuf.MessageType): reset_word_pos: Optional["int"] = None, mnemonic_type: Optional["BackupType"] = None, thp_pairing_code_entry_code: Optional["int"] = None, - thp_pairing_secret: Optional["bytes"] = None, + thp_pairing_code_qr_code: Optional["bytes"] = None, + thp_pairing_code_nfc_unidirectional: Optional["bytes"] = None, ) -> None: self.tokens: Sequence["str"] = tokens if tokens is not None else [] self.layout = layout @@ -4131,7 +4133,8 @@ class DebugLinkState(protobuf.MessageType): self.reset_word_pos = reset_word_pos self.mnemonic_type = mnemonic_type self.thp_pairing_code_entry_code = thp_pairing_code_entry_code - self.thp_pairing_secret = thp_pairing_secret + self.thp_pairing_code_qr_code = thp_pairing_code_qr_code + self.thp_pairing_code_nfc_unidirectional = thp_pairing_code_nfc_unidirectional class DebugLinkStop(protobuf.MessageType): diff --git a/rust/trezor-client/src/protos/generated/messages_debug.rs b/rust/trezor-client/src/protos/generated/messages_debug.rs index 54776df0a..4021a1d09 100644 --- a/rust/trezor-client/src/protos/generated/messages_debug.rs +++ b/rust/trezor-client/src/protos/generated/messages_debug.rs @@ -1492,8 +1492,10 @@ pub struct DebugLinkState { pub tokens: ::std::vec::Vec<::std::string::String>, // @@protoc_insertion_point(field:hw.trezor.messages.debug.DebugLinkState.thp_pairing_code_entry_code) pub thp_pairing_code_entry_code: ::std::option::Option, - // @@protoc_insertion_point(field:hw.trezor.messages.debug.DebugLinkState.thp_pairing_secret) - pub thp_pairing_secret: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.debug.DebugLinkState.thp_pairing_code_qr_code) + pub thp_pairing_code_qr_code: ::std::option::Option<::std::vec::Vec>, + // @@protoc_insertion_point(field:hw.trezor.messages.debug.DebugLinkState.thp_pairing_code_nfc_unidirectional) + pub thp_pairing_code_nfc_unidirectional: ::std::option::Option<::std::vec::Vec>, // special fields // @@protoc_insertion_point(special_field:hw.trezor.messages.debug.DebugLinkState.special_fields) pub special_fields: ::protobuf::SpecialFields, @@ -1860,44 +1862,80 @@ impl DebugLinkState { self.thp_pairing_code_entry_code = ::std::option::Option::Some(v); } - // optional bytes thp_pairing_secret = 15; + // optional bytes thp_pairing_code_qr_code = 15; - pub fn thp_pairing_secret(&self) -> &[u8] { - match self.thp_pairing_secret.as_ref() { + pub fn thp_pairing_code_qr_code(&self) -> &[u8] { + match self.thp_pairing_code_qr_code.as_ref() { Some(v) => v, None => &[], } } - pub fn clear_thp_pairing_secret(&mut self) { - self.thp_pairing_secret = ::std::option::Option::None; + pub fn clear_thp_pairing_code_qr_code(&mut self) { + self.thp_pairing_code_qr_code = ::std::option::Option::None; } - pub fn has_thp_pairing_secret(&self) -> bool { - self.thp_pairing_secret.is_some() + pub fn has_thp_pairing_code_qr_code(&self) -> bool { + self.thp_pairing_code_qr_code.is_some() } // Param is passed by value, moved - pub fn set_thp_pairing_secret(&mut self, v: ::std::vec::Vec) { - self.thp_pairing_secret = ::std::option::Option::Some(v); + pub fn set_thp_pairing_code_qr_code(&mut self, v: ::std::vec::Vec) { + self.thp_pairing_code_qr_code = ::std::option::Option::Some(v); } // Mutable pointer to the field. // If field is not initialized, it is initialized with default value first. - pub fn mut_thp_pairing_secret(&mut self) -> &mut ::std::vec::Vec { - if self.thp_pairing_secret.is_none() { - self.thp_pairing_secret = ::std::option::Option::Some(::std::vec::Vec::new()); + pub fn mut_thp_pairing_code_qr_code(&mut self) -> &mut ::std::vec::Vec { + if self.thp_pairing_code_qr_code.is_none() { + self.thp_pairing_code_qr_code = ::std::option::Option::Some(::std::vec::Vec::new()); } - self.thp_pairing_secret.as_mut().unwrap() + self.thp_pairing_code_qr_code.as_mut().unwrap() } // Take field - pub fn take_thp_pairing_secret(&mut self) -> ::std::vec::Vec { - self.thp_pairing_secret.take().unwrap_or_else(|| ::std::vec::Vec::new()) + pub fn take_thp_pairing_code_qr_code(&mut self) -> ::std::vec::Vec { + self.thp_pairing_code_qr_code.take().unwrap_or_else(|| ::std::vec::Vec::new()) + } + + // optional bytes thp_pairing_code_nfc_unidirectional = 16; + + pub fn thp_pairing_code_nfc_unidirectional(&self) -> &[u8] { + match self.thp_pairing_code_nfc_unidirectional.as_ref() { + Some(v) => v, + None => &[], + } + } + + pub fn clear_thp_pairing_code_nfc_unidirectional(&mut self) { + self.thp_pairing_code_nfc_unidirectional = ::std::option::Option::None; + } + + pub fn has_thp_pairing_code_nfc_unidirectional(&self) -> bool { + self.thp_pairing_code_nfc_unidirectional.is_some() + } + + // Param is passed by value, moved + pub fn set_thp_pairing_code_nfc_unidirectional(&mut self, v: ::std::vec::Vec) { + self.thp_pairing_code_nfc_unidirectional = ::std::option::Option::Some(v); + } + + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_thp_pairing_code_nfc_unidirectional(&mut self) -> &mut ::std::vec::Vec { + if self.thp_pairing_code_nfc_unidirectional.is_none() { + self.thp_pairing_code_nfc_unidirectional = ::std::option::Option::Some(::std::vec::Vec::new()); + } + self.thp_pairing_code_nfc_unidirectional.as_mut().unwrap() + } + + // Take field + pub fn take_thp_pairing_code_nfc_unidirectional(&mut self) -> ::std::vec::Vec { + self.thp_pairing_code_nfc_unidirectional.take().unwrap_or_else(|| ::std::vec::Vec::new()) } fn generated_message_descriptor_data() -> ::protobuf::reflect::GeneratedMessageDescriptorData { - let mut fields = ::std::vec::Vec::with_capacity(15); + let mut fields = ::std::vec::Vec::with_capacity(16); let mut oneofs = ::std::vec::Vec::with_capacity(0); fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( "layout", @@ -1970,9 +2008,14 @@ impl DebugLinkState { |m: &mut DebugLinkState| { &mut m.thp_pairing_code_entry_code }, )); fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( - "thp_pairing_secret", - |m: &DebugLinkState| { &m.thp_pairing_secret }, - |m: &mut DebugLinkState| { &mut m.thp_pairing_secret }, + "thp_pairing_code_qr_code", + |m: &DebugLinkState| { &m.thp_pairing_code_qr_code }, + |m: &mut DebugLinkState| { &mut m.thp_pairing_code_qr_code }, + )); + fields.push(::protobuf::reflect::rt::v2::make_option_accessor::<_, _>( + "thp_pairing_code_nfc_unidirectional", + |m: &DebugLinkState| { &m.thp_pairing_code_nfc_unidirectional }, + |m: &mut DebugLinkState| { &mut m.thp_pairing_code_nfc_unidirectional }, )); ::protobuf::reflect::GeneratedMessageDescriptorData::new_2::( "DebugLinkState", @@ -2040,7 +2083,10 @@ impl ::protobuf::Message for DebugLinkState { self.thp_pairing_code_entry_code = ::std::option::Option::Some(is.read_uint32()?); }, 122 => { - self.thp_pairing_secret = ::std::option::Option::Some(is.read_bytes()?); + self.thp_pairing_code_qr_code = ::std::option::Option::Some(is.read_bytes()?); + }, + 130 => { + self.thp_pairing_code_nfc_unidirectional = ::std::option::Option::Some(is.read_bytes()?); }, tag => { ::protobuf::rt::read_unknown_or_skip_group(tag, is, self.special_fields.mut_unknown_fields())?; @@ -2097,9 +2143,12 @@ impl ::protobuf::Message for DebugLinkState { if let Some(v) = self.thp_pairing_code_entry_code { my_size += ::protobuf::rt::uint32_size(14, v); } - if let Some(v) = self.thp_pairing_secret.as_ref() { + if let Some(v) = self.thp_pairing_code_qr_code.as_ref() { my_size += ::protobuf::rt::bytes_size(15, &v); } + if let Some(v) = self.thp_pairing_code_nfc_unidirectional.as_ref() { + my_size += ::protobuf::rt::bytes_size(16, &v); + } my_size += ::protobuf::rt::unknown_fields_size(self.special_fields.unknown_fields()); self.special_fields.cached_size().set(my_size as u32); my_size @@ -2148,9 +2197,12 @@ impl ::protobuf::Message for DebugLinkState { if let Some(v) = self.thp_pairing_code_entry_code { os.write_uint32(14, v)?; } - if let Some(v) = self.thp_pairing_secret.as_ref() { + if let Some(v) = self.thp_pairing_code_qr_code.as_ref() { os.write_bytes(15, v)?; } + if let Some(v) = self.thp_pairing_code_nfc_unidirectional.as_ref() { + os.write_bytes(16, v)?; + } os.write_unknown_fields(self.special_fields.unknown_fields())?; ::std::result::Result::Ok(()) } @@ -2182,7 +2234,8 @@ impl ::protobuf::Message for DebugLinkState { self.mnemonic_type = ::std::option::Option::None; self.tokens.clear(); self.thp_pairing_code_entry_code = ::std::option::Option::None; - self.thp_pairing_secret = ::std::option::Option::None; + self.thp_pairing_code_qr_code = ::std::option::Option::None; + self.thp_pairing_code_nfc_unidirectional = ::std::option::Option::None; self.special_fields.clear(); } @@ -2202,7 +2255,8 @@ impl ::protobuf::Message for DebugLinkState { mnemonic_type: ::std::option::Option::None, tokens: ::std::vec::Vec::new(), thp_pairing_code_entry_code: ::std::option::Option::None, - thp_pairing_secret: ::std::option::Option::None, + thp_pairing_code_qr_code: ::std::option::Option::None, + thp_pairing_code_nfc_unidirectional: ::std::option::Option::None, special_fields: ::protobuf::SpecialFields::new(), }; &instance @@ -3802,7 +3856,7 @@ static file_descriptor_proto_data: &'static [u8] = b"\ (\x0e29.hw.trezor.messages.debug.DebugLinkGetState.DebugWaitType:\tIMMED\ IATER\nwaitLayout\x12$\n\x0ethp_channel_id\x18\x04\x20\x01(\x0cR\x0cthpC\ hannelId\"C\n\rDebugWaitType\x12\r\n\tIMMEDIATE\x10\0\x12\x0f\n\x0bNEXT_\ - LAYOUT\x10\x01\x12\x12\n\x0eCURRENT_LAYOUT\x10\x02\"\x83\x05\n\x0eDebugL\ + LAYOUT\x10\x01\x12\x12\n\x0eCURRENT_LAYOUT\x10\x02\"\xdb\x05\n\x0eDebugL\ inkState\x12\x16\n\x06layout\x18\x01\x20\x01(\x0cR\x06layout\x12\x10\n\ \x03pin\x18\x02\x20\x01(\tR\x03pin\x12\x16\n\x06matrix\x18\x03\x20\x01(\ \tR\x06matrix\x12'\n\x0fmnemonic_secret\x18\x04\x20\x01(\x0cR\x0emnemoni\ @@ -3816,21 +3870,23 @@ static file_descriptor_proto_data: &'static [u8] = b"\ \x18\x0c\x20\x01(\x0e2).hw.trezor.messages.management.BackupTypeR\x0cmne\ monicType\x12\x16\n\x06tokens\x18\r\x20\x03(\tR\x06tokens\x12<\n\x1bthp_\ pairing_code_entry_code\x18\x0e\x20\x01(\rR\x17thpPairingCodeEntryCode\ - \x12,\n\x12thp_pairing_secret\x18\x0f\x20\x01(\x0cR\x10thpPairingSecret\ - \"\x0f\n\rDebugLinkStop\"P\n\x0cDebugLinkLog\x12\x14\n\x05level\x18\x01\ - \x20\x01(\rR\x05level\x12\x16\n\x06bucket\x18\x02\x20\x01(\tR\x06bucket\ - \x12\x12\n\x04text\x18\x03\x20\x01(\tR\x04text\"G\n\x13DebugLinkMemoryRe\ - ad\x12\x18\n\x07address\x18\x01\x20\x01(\rR\x07address\x12\x16\n\x06leng\ - th\x18\x02\x20\x01(\rR\x06length\")\n\x0fDebugLinkMemory\x12\x16\n\x06me\ - mory\x18\x01\x20\x01(\x0cR\x06memory\"^\n\x14DebugLinkMemoryWrite\x12\ - \x18\n\x07address\x18\x01\x20\x01(\rR\x07address\x12\x16\n\x06memory\x18\ - \x02\x20\x01(\x0cR\x06memory\x12\x14\n\x05flash\x18\x03\x20\x01(\x08R\ - \x05flash\"-\n\x13DebugLinkFlashErase\x12\x16\n\x06sector\x18\x01\x20\ - \x01(\rR\x06sector\".\n\x14DebugLinkEraseSdCard\x12\x16\n\x06format\x18\ - \x01\x20\x01(\x08R\x06format\"0\n\x14DebugLinkWatchLayout\x12\x14\n\x05w\ - atch\x18\x01\x20\x01(\x08R\x05watch:\x02\x18\x01\"\x1f\n\x19DebugLinkRes\ - etDebugEvents:\x02\x18\x01\"\x1a\n\x18DebugLinkOptigaSetSecMaxB=\n#com.s\ - atoshilabs.trezor.lib.protobufB\x12TrezorMessageDebug\x80\xa6\x1d\x01\ + \x126\n\x18thp_pairing_code_qr_code\x18\x0f\x20\x01(\x0cR\x14thpPairingC\ + odeQrCode\x12L\n#thp_pairing_code_nfc_unidirectional\x18\x10\x20\x01(\ + \x0cR\x1fthpPairingCodeNfcUnidirectional\"\x0f\n\rDebugLinkStop\"P\n\x0c\ + DebugLinkLog\x12\x14\n\x05level\x18\x01\x20\x01(\rR\x05level\x12\x16\n\ + \x06bucket\x18\x02\x20\x01(\tR\x06bucket\x12\x12\n\x04text\x18\x03\x20\ + \x01(\tR\x04text\"G\n\x13DebugLinkMemoryRead\x12\x18\n\x07address\x18\ + \x01\x20\x01(\rR\x07address\x12\x16\n\x06length\x18\x02\x20\x01(\rR\x06l\ + ength\")\n\x0fDebugLinkMemory\x12\x16\n\x06memory\x18\x01\x20\x01(\x0cR\ + \x06memory\"^\n\x14DebugLinkMemoryWrite\x12\x18\n\x07address\x18\x01\x20\ + \x01(\rR\x07address\x12\x16\n\x06memory\x18\x02\x20\x01(\x0cR\x06memory\ + \x12\x14\n\x05flash\x18\x03\x20\x01(\x08R\x05flash\"-\n\x13DebugLinkFlas\ + hErase\x12\x16\n\x06sector\x18\x01\x20\x01(\rR\x06sector\".\n\x14DebugLi\ + nkEraseSdCard\x12\x16\n\x06format\x18\x01\x20\x01(\x08R\x06format\"0\n\ + \x14DebugLinkWatchLayout\x12\x14\n\x05watch\x18\x01\x20\x01(\x08R\x05wat\ + ch:\x02\x18\x01\"\x1f\n\x19DebugLinkResetDebugEvents:\x02\x18\x01\"\x1a\ + \n\x18DebugLinkOptigaSetSecMaxB=\n#com.satoshilabs.trezor.lib.protobufB\ + \x12TrezorMessageDebug\x80\xa6\x1d\x01\ "; /// `FileDescriptorProto` object which was a source for this generated file