Skip to content

Commit

Permalink
python: fix padding in first chunk (fixes #1082)
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik committed Jun 25, 2020
1 parent 6ebb388 commit 312d6ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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._

## [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]: https://github.com/trezor/trezor-firmware/compare/python/v0.11.6...python/v0.12.0

Expand Down Expand Up @@ -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#778]: https://github.com/trezor/trezor-firmware/issues/778
[f#823]: https://github.com/trezor/trezor-firmware/issues/823
[f#1082]: https://github.com/trezor/trezor-firmware/issues/1082
2 changes: 1 addition & 1 deletion python/src/trezorlib/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def calculate_code_hashes(
chunk = code[start:end]
# padding for last non-empty chunk
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:
hashes.append(b"\0" * 32)
Expand Down

0 comments on commit 312d6ea

Please sign in to comment.