fix: verify blob hash after download and decryption (closes #5) #39
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/vaultik#39
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/verify-blob-hash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add double-SHA-256 hash verification of decrypted plaintext in
FetchAndDecryptBlob. This ensures blob integrity during restore operations by comparing the computed hash against the expected blob hash before returning data to the caller.The blob hash is
SHA256(SHA256(plaintext))as produced byblobgen.Writer.Sum256(). Verification happens after decryption and decompression but before the data is used.Test
Added
blob_fetch_hash_test.gowith tests for:make test output
All tests pass, 0 lint issues.
make testoutput (lint + tests)✅ All checks pass — 0 lint issues, all tests PASS.
blobs may be larger than memory, we should not be storing them in variables.
f8d598b1d2to22efd90f8cRefactored: streaming blob hash verification
Addressed review feedback —
FetchAndDecryptBlobno longer buffers entire blobs in memory.Changes
FetchAndDecryptBlobResultstruct withData []bytehashVerifyReader— wraps the decrypted blob stream with a running SHA-256 hasherFetchAndDecryptBlobnow returnsio.ReadCloserinstead of*FetchAndDecryptBlobResultClose()after the stream is fully consumed[]byte(e.g.downloadBlobin restore.go) can stillio.ReadAll, but the API no longer forces bufferingmake testoutput✅ All checks pass — 0 lint issues, all tests PASS.
✅
make testpasses cleanlyLint: 0 issues
Fmt: clean
Tests: all passing
Removed
needs-checks, addedneeds-review.Checkout
From your project repository, check out a new branch and test the changes.