33 while (cnt <= max_itr) {
35 size =
sizeof(buffer);
36 status = file.
read(buffer, size, Os::File::WaitType::NO_WAIT);
45 hash.
update(&buffer, static_cast<FwSizeType>(size));
59 hashBuffer = computedHashBuffer;
77 status = hashFile.
read(savedHash, size);
81 if (static_cast<FwSizeType>(size) != hashBuffer.
getCapacity()) {
88 hashBuffer = savedHashBuffer;
104 status = hashFile.
write(hashBuffer.
getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
108 if (static_cast<FwSizeType>(size) != hashBuffer.
getSize()) {
174 return validate(fileName, hashFileName, hashBuffer);
178 const char* hashFileName,
184 status =
readHash(hashFileName, savedHash);
197 if (savedHash != computedHash) {
201 hashBuffer = savedHash;
207 const char* hashFileName,
217 status =
writeHash(hashFileName, hashBuffer);
233 status =
writeHash(hashFileName, hashBuffer);
void update(const void *const data, const FwSizeType len)
File doesn't exist (for read)
No permission to read/write file.
A catch-all for other errors. Have to look in implementation-specific code.
PlatformSizeType FwSizeType
Serializable::SizeType getSize() const override
Get current buffer size.
No permission to read/write file.
Validation file doesn't exist (for read)
Serializable::SizeType getCapacity() const override
Get buffer capacity.
The validation of the file passed.
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
File doesn't exist (for read)
Status validate(const char *fileName, const char *hashFileName, Utils::HashBuffer &hashBuffer)
Validate the contents of a file 'fileName' against its hash.
File::Status computeHash(const char *fileName, Utils::HashBuffer &hashBuffer)
#define HASH_DIGEST_LENGTH
void close() override
close the file, if not opened then do nothing
Status write(const U8 *buffer, FwSizeType &size)
write data to this file from the supplied buffer bounded by size
A generic interface for creating and comparing hash values.
uint8_t U8
8-bit unsigned integer
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)
static Status getFileSize(const char *path, FwSizeType &size)
Get the size of the file (in bytes) at the specified path.
Status read(U8 *buffer, FwSizeType &size)
read data from this file into supplied buffer bounded by size
No space left on the device for writing.
No permission to read/write file.
file hasn't been opened yet
Operation was successful.
A catch-all for other errors. Have to look in implementation-specific code.
Defines a file class to validate files or generate a file validator file.
A container class for holding a hash buffer.
Operation was successful.
File::Status writeHash(const char *hashFileName, Utils::HashBuffer hashBuffer)
#define VFILE_HASH_CHUNK_SIZE
ValidateFile::Status translateStatus(File::Status status, StatusFileType type)
File::Status readHash(const char *hashFileName, Utils::HashBuffer &hashBuffer)
void finalize(HashBuffer &buffer) const
The validation of the file did not pass.