mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-26 14:22:06 +00:00
feat(core/ethereum): remove EIP-712 field size limitation of 1024 bytes
This commit is contained in:
parent
72ef41664f
commit
c068c668fa
1
core/.changelog.d/2746.changed
Normal file
1
core/.changelog.d/2746.changed
Normal file
@ -0,0 +1 @@
|
||||
Ethereum's EIP-712 signing no longer restricts the maximum field size to 1024 bytes.
|
@ -1,4 +1,3 @@
|
||||
from micropython import const
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from trezor.enums import EthereumDataType
|
||||
@ -21,10 +20,6 @@ if TYPE_CHECKING:
|
||||
)
|
||||
|
||||
|
||||
# Maximum data size we support
|
||||
_MAX_VALUE_BYTE_SIZE = const(1024)
|
||||
|
||||
|
||||
@with_keychain_from_path(*PATTERNS_ADDRESS)
|
||||
async def sign_typed_data(
|
||||
ctx: Context, msg: EthereumSignTypedData, keychain: Keychain
|
||||
@ -426,14 +421,12 @@ def _validate_value(field: EthereumFieldType, value: bytes) -> None:
|
||||
|
||||
Raise DataError if encountering a problem, so clients are notified.
|
||||
"""
|
||||
# Checking if the size corresponds to what is defined in types,
|
||||
# and also setting our maximum supported size in bytes
|
||||
if field.size is not None:
|
||||
if len(value) != field.size:
|
||||
raise DataError("Invalid length")
|
||||
else:
|
||||
if len(value) > _MAX_VALUE_BYTE_SIZE:
|
||||
raise DataError(f"Invalid length, bigger than {_MAX_VALUE_BYTE_SIZE}")
|
||||
# Checking if the size corresponds to what is defined in types.
|
||||
# Not having any maximum field size - it is a responsibility of the client
|
||||
# (and message creator) to make sure the data is not too large to cause problems
|
||||
# on the Trezor side.
|
||||
if field.size is not None and len(value) != field.size:
|
||||
raise DataError("Invalid length")
|
||||
|
||||
# Specific tests for some data types
|
||||
if field.data_type == EthereumDataType.BOOL:
|
||||
|
@ -582,8 +582,8 @@ class TestEthereumSignTypedData(unittest.TestCase):
|
||||
),
|
||||
(
|
||||
EFT(data_type=EDT.STRING, size=None),
|
||||
[b"\x7f", b"a" * 1024],
|
||||
[b"\x80", b"a" * 1025],
|
||||
[b"\x7f"],
|
||||
[b"\x80"],
|
||||
),
|
||||
(
|
||||
EFT(data_type=EDT.ADDRESS, size=None),
|
||||
|
Loading…
Reference in New Issue
Block a user