mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-04 22:02:34 +00:00
python: fix padding in first chunk (fixes #1082)
This commit is contained in:
parent
6ebb388905
commit
312d6ea822
@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
|
|
||||||
_At the moment, the project does **not** adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). That is expected to change with version 1.0._
|
_At the moment, the project does **not** adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). That is expected to change with version 1.0._
|
||||||
|
|
||||||
|
## [0.12.1] - unreleased
|
||||||
|
[0.12.1]: https://github.com/trezor/trezor-firmware/compare/python/v0.12.0...master
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- correctly calculate hashes for very small firmwares [f#1082]
|
||||||
|
|
||||||
## [0.12.0] - 2020-04-01
|
## [0.12.0] - 2020-04-01
|
||||||
[0.12.0]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.6...python/v0.12.0
|
[0.12.0]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.6...python/v0.12.0
|
||||||
|
|
||||||
@ -422,3 +429,4 @@ _At the moment, the project does **not** adhere to [Semantic Versioning](https:/
|
|||||||
[f#681]: https://github.com/trezor/trezor-firmware/issues/681
|
[f#681]: https://github.com/trezor/trezor-firmware/issues/681
|
||||||
[f#778]: https://github.com/trezor/trezor-firmware/issues/778
|
[f#778]: https://github.com/trezor/trezor-firmware/issues/778
|
||||||
[f#823]: https://github.com/trezor/trezor-firmware/issues/823
|
[f#823]: https://github.com/trezor/trezor-firmware/issues/823
|
||||||
|
[f#1082]: https://github.com/trezor/trezor-firmware/issues/1082
|
||||||
|
@ -363,7 +363,7 @@ def calculate_code_hashes(
|
|||||||
chunk = code[start:end]
|
chunk = code[start:end]
|
||||||
# padding for last non-empty chunk
|
# padding for last non-empty chunk
|
||||||
if padding_byte is not None and start < len(code) and end > len(code):
|
if padding_byte is not None and start < len(code) and end > len(code):
|
||||||
chunk += padding_byte[0:1] * (chunk_size - len(chunk))
|
chunk += padding_byte[0:1] * (end - start - len(chunk))
|
||||||
|
|
||||||
if not chunk:
|
if not chunk:
|
||||||
hashes.append(b"\0" * 32)
|
hashes.append(b"\0" * 32)
|
||||||
|
Loading…
Reference in New Issue
Block a user