mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-26 16:18:22 +00:00
Updated to latest from bech32 repository.
hrp is ASCII character, not 5 bit words
This commit is contained in:
parent
a5653dafe7
commit
f366fb81c5
@ -51,9 +51,13 @@ int bech32_encode(char *output, const char *hrp, const uint8_t *data, size_t dat
|
|||||||
uint32_t chk = 1;
|
uint32_t chk = 1;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (hrp[i] != 0) {
|
while (hrp[i] != 0) {
|
||||||
if (hrp[i] >= 'A' && hrp[i] <= 'Z') return 0;
|
int ch = hrp[i];
|
||||||
if (!(hrp[i] >> 5)) return 0;
|
if (ch < 33 || ch > 126) {
|
||||||
chk = bech32_polymod_step(chk) ^ (hrp[i] >> 5);
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch >= 'A' && ch <= 'Z') return 0;
|
||||||
|
chk = bech32_polymod_step(chk) ^ (ch >> 5);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if (i + 7 + data_len > 90) return 0;
|
if (i + 7 + data_len > 90) return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user