1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-02-08 05:32:39 +00:00

feat(core): remove even more logging

[no changelog]
This commit is contained in:
M1nd3r 2024-10-20 00:02:15 +02:00
parent 38fbfc7a61
commit 31c3c5c896
5 changed files with 8 additions and 12 deletions

View File

@ -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 Set the expected sequential number (bit) of the next message to be received
in the provided channel 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) log.debug(__name__, "Set sync receive expected seq bit to %d", seq_bit)
if seq_bit not in (0, 1): if seq_bit not in (0, 1):
raise ThpError("Unexpected receive sync bit") 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: def _set_send_seq_bit(cache: ChannelCache, seq_bit: int) -> None:
if seq_bit not in (0, 1): if seq_bit not in (0, 1):
raise ThpError("Unexpected send seq bit") 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) log.debug(__name__, "setting sync send seq bit to %d", seq_bit)
# set third bit to "seq_bit" value # set third bit to "seq_bit" value
cache.sync &= 0xDF cache.sync &= 0xDF

View File

@ -44,7 +44,7 @@ if TYPE_CHECKING:
class Channel: class Channel:
def __init__(self, channel_cache: ChannelCache) -> None: def __init__(self, channel_cache: ChannelCache) -> None:
if __debug__: if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
log.debug(__name__, "channel initialization") log.debug(__name__, "channel initialization")
self.iface: WireInterface = interface_manager.decode_iface(channel_cache.iface) self.iface: WireInterface = interface_manager.decode_iface(channel_cache.iface)
self.channel_cache: ChannelCache = channel_cache self.channel_cache: ChannelCache = channel_cache

View File

@ -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). Encrypts the provided `buffer` with AES-GCM (in place).
Returns a 16-byte long encryption tag. 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) log.debug(__name__, "enc (key: %s, nonce: %d)", hexlify(key), nonce)
iv = _get_iv_from_nonce(nonce) iv = _get_iv_from_nonce(nonce)
aes_ctx = aesgcm(key, iv) aes_ctx = aesgcm(key, iv)
@ -39,7 +39,7 @@ def dec(
the tag computed in decryption, otherwise it returns `False`. the tag computed in decryption, otherwise it returns `False`.
""" """
iv = _get_iv_from_nonce(nonce) 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) log.debug(__name__, "dec (key: %s, nonce: %d)", hexlify(key), nonce)
aes_ctx = aesgcm(key, iv) aes_ctx = aesgcm(key, iv)
aes_ctx.auth(auth_data) aes_ctx.auth(auth_data)

View File

@ -36,7 +36,7 @@ class GenericSessionContext(Context):
self.handler_finder: HandlerFinder = find_handler self.handler_finder: HandlerFinder = find_handler
async def handle(self) -> None: async def handle(self) -> None:
if __debug__: if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
self._handle_debug() self._handle_debug()
next_message: Message | None = None next_message: Message | None = None
@ -63,10 +63,6 @@ class GenericSessionContext(Context):
get_bytes_as_str(self.channel_id), get_bytes_as_str(self.channel_id),
self.session_id, self.session_id,
) )
# if is_debug_session:
# import apps.debug
# apps.debug.DEBUG_CONTEXT = self
async def _handle_message( async def _handle_message(
self, self,
@ -124,7 +120,7 @@ class GenericSessionContext(Context):
expected_types: Container[int], expected_types: Container[int],
expected_type: type[protobuf.MessageType] | None = None, expected_type: type[protobuf.MessageType] | None = None,
) -> protobuf.MessageType: ) -> protobuf.MessageType:
if __debug__: if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
exp_type: str = str(expected_type) exp_type: str = str(expected_type)
if expected_type is not None: if expected_type is not None:
exp_type = expected_type.MESSAGE_NAME exp_type = expected_type.MESSAGE_NAME

View File

@ -62,7 +62,7 @@ async def thp_main_loop(iface: WireInterface):
while True: while True:
try: try:
if __debug__: if __debug__ and utils.ALLOW_DEBUG_MESSAGES:
log.debug(__name__, "thp_main_loop") log.debug(__name__, "thp_main_loop")
packet = await read packet = await read
ctrl_byte, cid = ustruct.unpack(">BH", packet) ctrl_byte, cid = ustruct.unpack(">BH", packet)