Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the behavior of complete_verified_as function
`complete_verified_as` finishes writing the blob, verifying its digest and size against the expected descriptor, and then writing the contents to a file with a completely different sha256 digest. The reason is that both `complete_verified_as` and `complete` call self.hash.finish(), but this function can only be called once, because after the first call it transitions into the Finalized state [1]. The second time it gets called it realizes it's in the Finalized state and then it calls self.init, resetting the hasher. This is a bad API design. Fix this by only calling self.hash.finish() once and then passing the result to a new internal function `complete_as`, which does the same thing as `complete` but avoids calling self.hash.finish() again. Add a test to ensure `complete_verified_as` behaves as expected. [1] https://docs.rs/openssl/0.10.66/src/openssl/hash.rs.html#295-297 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
- Loading branch information