Expand description
Integrity checking for anything fetched over the network. Compiled always, feature flags or not, so its tests cannot be skipped out of CI. Integrity checking for files fetched over the network.
§Why this module exists
The PaddleOCR backend used to fetch up to ~84 MB of ONNX model weights from a third-party public repository and write them straight to the cache, with no integrity check of any kind. Whoever served those bytes decided what our inference engine executed. For an SDK sold on privacy and on not phoning home, that is the wrong default — and a warning in the README is not a fix, it is a note explaining why the product is wrong.
So fetching is now opt-in and always verified, and this module is the
verification. It is compiled unconditionally, without the paddle feature,
for one specific reason: tests behind a non-default feature flag do not run in
CI, and a security check whose tests never execute is indistinguishable from no
check at all. That exact mistake has cost this project three regressions.
Enums§
- Integrity
Error - Why a downloaded file was rejected.
- Stream
Integrity Error - Why a streamed verification failed: the read itself, or the digest.
Functions§
- sha256_
hex - Hex-encoded SHA-256 of
bytes. - sha256_
hex_ of_ reader - Hex-encoded SHA-256 of a stream, read 64 KiB at a time.
- verify_
reader_ sha256 - Check a stream against an expected hex SHA-256 without holding it in memory.
- verify_
sha256 - Check
bytesagainst an expected hex SHA-256.