mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-01 10:20:59 +00:00
feat(core): remove even more logging
[no changelog]
This commit is contained in:
parent
38fbfc7a61
commit
31c3c5c896
@ -72,7 +72,7 @@ def set_expected_receive_seq_bit(cache: ChannelCache, seq_bit: int) -> None:
|
||||
Set the expected sequential number (bit) of the next message to be received
|
||||
in the provided channel
|
||||
"""
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "Set sync receive expected seq bit to %d", seq_bit)
|
||||
if seq_bit not in (0, 1):
|
||||
raise ThpError("Unexpected receive sync bit")
|
||||
@ -86,7 +86,7 @@ def set_expected_receive_seq_bit(cache: ChannelCache, seq_bit: int) -> None:
|
||||
def _set_send_seq_bit(cache: ChannelCache, seq_bit: int) -> None:
|
||||
if seq_bit not in (0, 1):
|
||||
raise ThpError("Unexpected send seq bit")
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "setting sync send seq bit to %d", seq_bit)
|
||||
# set third bit to "seq_bit" value
|
||||
cache.sync &= 0xDF
|
||||
|
@ -44,7 +44,7 @@ if TYPE_CHECKING:
|
||||
|
||||
class Channel:
|
||||
def __init__(self, channel_cache: ChannelCache) -> None:
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "channel initialization")
|
||||
self.iface: WireInterface = interface_manager.decode_iface(channel_cache.iface)
|
||||
self.channel_cache: ChannelCache = channel_cache
|
||||
|
@ -22,7 +22,7 @@ def enc(buffer: utils.BufferType, key: bytes, nonce: int, auth_data: bytes) -> b
|
||||
Encrypts the provided `buffer` with AES-GCM (in place).
|
||||
Returns a 16-byte long encryption tag.
|
||||
"""
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "enc (key: %s, nonce: %d)", hexlify(key), nonce)
|
||||
iv = _get_iv_from_nonce(nonce)
|
||||
aes_ctx = aesgcm(key, iv)
|
||||
@ -39,7 +39,7 @@ def dec(
|
||||
the tag computed in decryption, otherwise it returns `False`.
|
||||
"""
|
||||
iv = _get_iv_from_nonce(nonce)
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "dec (key: %s, nonce: %d)", hexlify(key), nonce)
|
||||
aes_ctx = aesgcm(key, iv)
|
||||
aes_ctx.auth(auth_data)
|
||||
|
@ -36,7 +36,7 @@ class GenericSessionContext(Context):
|
||||
self.handler_finder: HandlerFinder = find_handler
|
||||
|
||||
async def handle(self) -> None:
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
self._handle_debug()
|
||||
|
||||
next_message: Message | None = None
|
||||
@ -63,10 +63,6 @@ class GenericSessionContext(Context):
|
||||
get_bytes_as_str(self.channel_id),
|
||||
self.session_id,
|
||||
)
|
||||
# if is_debug_session:
|
||||
# import apps.debug
|
||||
|
||||
# apps.debug.DEBUG_CONTEXT = self
|
||||
|
||||
async def _handle_message(
|
||||
self,
|
||||
@ -124,7 +120,7 @@ class GenericSessionContext(Context):
|
||||
expected_types: Container[int],
|
||||
expected_type: type[protobuf.MessageType] | None = None,
|
||||
) -> protobuf.MessageType:
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
exp_type: str = str(expected_type)
|
||||
if expected_type is not None:
|
||||
exp_type = expected_type.MESSAGE_NAME
|
||||
|
@ -62,7 +62,7 @@ async def thp_main_loop(iface: WireInterface):
|
||||
|
||||
while True:
|
||||
try:
|
||||
if __debug__:
|
||||
if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
|
||||
log.debug(__name__, "thp_main_loop")
|
||||
packet = await read
|
||||
ctrl_byte, cid = ustruct.unpack(">BH", packet)
|
||||
|
Loading…
Reference in New Issue
Block a user