35 while( cnt <= max_itr ) {
37 size =
sizeof(buffer);
38 status = file.
read(buffer, size, Os::File::WaitType::NO_WAIT);
47 hash.
update(&buffer, static_cast<NATIVE_INT_TYPE>(size));
58 hash.
final(computedHashBuffer);
59 hashBuffer = computedHashBuffer;
78 status = hashFile.
read(savedHash, size);
82 if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.
getBuffCapacity()) ) {
88 Utils::HashBuffer savedHashBuffer(savedHash, static_cast<NATIVE_UINT_TYPE>(size));
89 hashBuffer = savedHashBuffer;
105 status = hashFile.
write(hashBuffer.
getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
109 if( size != static_cast<NATIVE_INT_TYPE>(hashBuffer.
getBuffLength()) ) {
175 return validate(fileName, hashFileName, hashBuffer);
184 status =
readHash(hashFileName, savedHash);
197 if( savedHash != computedHash ){
201 hashBuffer = savedHash;
216 status =
writeHash(hashFileName, hashBuffer);
File doesn't exist (for read)
#define HASH_DIGEST_LENGTH
No permission to read/write file.
A catch-all for other errors. Have to look in implementation-specific code.
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
PlatformIntType NATIVE_INT_TYPE
No permission to read/write file.
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Validation file doesn't exist (for read)
void final(HashBuffer &buffer)
NATIVE_UINT_TYPE getBuffCapacity() const
The validation of the file passed.
Serializable::SizeType getBuffLength() const
returns current buffer size
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)
void close() override
close the file, if not opened then do nothing
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)
No space left on the device for writing.
No permission to read/write file.
file hasn't been opened yet
Operation was successful.
void update(const void *const data, const NATIVE_INT_TYPE len)
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.
PlatformSignedSizeType FwSignedSizeType
static Status getFileSize(const char *path, FwSignedSizeType &size)
Get the size of the file (in bytes) at the specified path.
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)
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
The validation of the file did not pass.