mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-26 00:08:10 +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;
|
||||
size_t i = 0;
|
||||
while (hrp[i] != 0) {
|
||||
if (hrp[i] >= 'A' && hrp[i] <= 'Z') return 0;
|
||||
if (!(hrp[i] >> 5)) return 0;
|
||||
chk = bech32_polymod_step(chk) ^ (hrp[i] >> 5);
|
||||
int ch = hrp[i];
|
||||
if (ch < 33 || ch > 126) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ch >= 'A' && ch <= 'Z') return 0;
|
||||
chk = bech32_polymod_step(chk) ^ (ch >> 5);
|
||||
++i;
|
||||
}
|
||||
if (i + 7 + data_len > 90) return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user