class BlobVerifier
Defined at line 25 of file ../../src/storage/blobfs/blob_verifier.h
BlobVerifier verifies the contents of a blob against a merkle tree. Thread-safe.
Public Methods
zx::result<std::unique_ptr<BlobVerifier>> Create (Digest digest, std::shared_ptr<BlobfsMetrics> metrics, std::span<const uint8_t> merkle_data_blocks, const BlobLayout & layout)
Creates an instance of BlobVerifier for blobs named |digest|, using the provided merkle tree
which is at most |merkle_size| bytes. The passed-in BlobfsMetrics will be updated when this
class runs.
The passed-in mapped merkle_data_blocks contains the blocks loaded from disk. The tree is
copied into the member `merkle_data_`.
Returns an error if the merkle tree's root does not match |digest|, or if the required tree
size for |data_size| bytes is bigger than |merkle_size|.
Defined at line 34 of file ../../src/storage/blobfs/blob_verifier.cc
zx_status_t Align (size_t * data_off, size_t * buf_len)
Modifies |data_off| and |buf_len| to be aligned to the minimum number of merkle tree nodes that
covered their original range.
Defined at line 62 of file ../../src/storage/blobfs/blob_verifier.h
const Digest & digest ()
Defined at line 66 of file ../../src/storage/blobfs/blob_verifier.h
std::span<const uint8_t> merkle_data ()
Defined at line 67 of file ../../src/storage/blobfs/blob_verifier.h
zx::result<std::unique_ptr<BlobVerifier>> CreateWithoutTree (Digest digest, std::shared_ptr<BlobfsMetrics> metrics, size_t data_size)
Creates an instance of BlobVerifier for blobs named |digest|, which are small enough to not
have a stored merkle tree (i.e. MerkleTreeBytes(data_size) == 0). The passed-in BlobfsMetrics
will be updated when this class runs.
Defined at line 70 of file ../../src/storage/blobfs/blob_verifier.cc
zx_status_t Verify (const void * data, size_t data_size, size_t buffer_size)
Verifies the entire contents of a blob. |buffer_size| is the total size of the buffer and the
buffer must be zeroed from |data_size| to |buffer_size|.
TODO(https://fxbug.dev/42121983): Make const if MerkleTreeVerifier::Verify becomes const
Defined at line 121 of file ../../src/storage/blobfs/blob_verifier.cc
zx_status_t VerifyPartial (const void * data, size_t length, size_t data_offset, size_t buffer_size)
Verifies a range of the contents of a blob from [data_offset, data_offset + length).
IMPORTANT: |data| is expected to be a pointer to the blob's contents at |data_offset|, not the
absolute start of the blob's data. (This facilitates partial verification when the blob is only
partially mapped in.) |buffer_size| is the total size of the buffer (relative to |data|) and
the buffer must be zeroed from |data_size| to |buffer_size|.
TODO(https://fxbug.dev/42121983): Make const if MerkleTreeVerifier::Verify becomes const
Defined at line 145 of file ../../src/storage/blobfs/blob_verifier.cc