mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 02:48:18 +00:00
legacy/firmware: fix ethereum message signing (#153)
If the length of the message was exactly a power of `10` the initial `1` was omitted.
This commit is contained in:
parent
f7d41cbbd7
commit
fc3a93dc47
@ -630,39 +630,39 @@ static void ethereum_message_hash(const uint8_t *message, size_t message_len,
|
|||||||
sha3_256_Init(&ctx);
|
sha3_256_Init(&ctx);
|
||||||
sha3_Update(&ctx, (const uint8_t *)"\x19" "Ethereum Signed Message:\n", 26);
|
sha3_Update(&ctx, (const uint8_t *)"\x19" "Ethereum Signed Message:\n", 26);
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
if (message_len > 1000000000) {
|
if (message_len >= 1000000000) {
|
||||||
c = '0' + message_len / 1000000000 % 10;
|
c = '0' + message_len / 1000000000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 100000000) {
|
if (message_len >= 100000000) {
|
||||||
c = '0' + message_len / 100000000 % 10;
|
c = '0' + message_len / 100000000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 10000000) {
|
if (message_len >= 10000000) {
|
||||||
c = '0' + message_len / 10000000 % 10;
|
c = '0' + message_len / 10000000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 1000000) {
|
if (message_len >= 1000000) {
|
||||||
c = '0' + message_len / 1000000 % 10;
|
c = '0' + message_len / 1000000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 100000) {
|
if (message_len >= 100000) {
|
||||||
c = '0' + message_len / 100000 % 10;
|
c = '0' + message_len / 100000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 10000) {
|
if (message_len >= 10000) {
|
||||||
c = '0' + message_len / 10000 % 10;
|
c = '0' + message_len / 10000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 1000) {
|
if (message_len >= 1000) {
|
||||||
c = '0' + message_len / 1000 % 10;
|
c = '0' + message_len / 1000 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 100) {
|
if (message_len >= 100) {
|
||||||
c = '0' + message_len / 100 % 10;
|
c = '0' + message_len / 100 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
if (message_len > 10) {
|
if (message_len >= 10) {
|
||||||
c = '0' + message_len / 10 % 10;
|
c = '0' + message_len / 10 % 10;
|
||||||
sha3_Update(&ctx, &c, 1);
|
sha3_Update(&ctx, &c, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user