35 while( cnt <= max_itr ) {
37 size =
sizeof(buffer);
38 status = file.
read(buffer, size, Os::File::WaitType::NO_WAIT);
58 hash.
final(computedHashBuffer);
59 hashBuffer = computedHashBuffer;
78 status = hashFile.
read(savedHash, size);
89 hashBuffer = savedHashBuffer;
105 status = hashFile.
write(hashBuffer.
getBuffAddr(), size, Os::File::WaitType::NO_WAIT);
175 return validate(fileName, hashFileName, hashBuffer);
184 status =
readHash(hashFileName, savedHash);
197 if( savedHash != computedHash ){
201 hashBuffer = savedHash;
216 status =
writeHash(hashFileName, hashBuffer);
PlatformIntType NATIVE_INT_TYPE
uint8_t U8
8-bit unsigned integer
PlatformUIntType NATIVE_UINT_TYPE
#define HASH_DIGEST_LENGTH
PlatformSignedSizeType FwSignedSizeType
Defines a file class to validate files or generate a file validator file.
#define VFILE_HASH_CHUNK_SIZE
Serializable::SizeType getBuffLength() const
returns current buffer size
Status read(U8 *buffer, FwSignedSizeType &size)
read data from this file into supplied buffer bounded by size
void close() override
close the file, if not opened then do nothing
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
Status write(const U8 *buffer, FwSignedSizeType &size)
write data to this file from the supplied buffer bounded by size
@ NO_PERMISSION
No permission to read/write file.
@ NOT_OPENED
file hasn't been opened yet
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ BAD_SIZE
Invalid size parameter.
@ OP_OK
Operation was successful.
@ DOESNT_EXIST
File doesn't exist (for read)
@ OPEN_WRITE
Open file for writing.
@ OPEN_READ
Open file for reading.
static Status getFileSize(const char *path, FwSignedSizeType &size)
Get the size of the file (in bytes) at the specified path.
@ OP_OK
Operation was successful.
A container class for holding a hash buffer.
NATIVE_UINT_TYPE getBuffCapacity() const
A generic interface for creating and comparing hash values.
void update(const void *const data, const NATIVE_INT_TYPE len)
void final(HashBuffer &buffer)
@ FILE_NO_PERMISSION
No permission to read/write file.
@ VALIDATION_OK
The validation of the file passed.
@ VALIDATION_FILE_DOESNT_EXIST
Validation file doesn't exist (for read)
@ FILE_DOESNT_EXIST
File doesn't exist (for read)
@ VALIDATION_FAIL
The validation of the file did not pass.
@ OTHER_ERROR
A catch-all for other errors. Have to look in implementation-specific code.
@ FILE_BAD_SIZE
Invalid size parameter.
@ NO_SPACE
No space left on the device for writing.
@ VALIDATION_FILE_BAD_SIZE
Invalid size parameter.
@ VALIDATION_FILE_NO_PERMISSION
No permission to read/write file.
Status createValidation(const char *fileName, const char *hash, Utils::HashBuffer &hashBuffer)
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)
File::Status readHash(const char *hashFileName, Utils::HashBuffer &hashBuffer)
File::Status writeHash(const char *hashFileName, Utils::HashBuffer hashBuffer)
ValidateFile::Status translateStatus(File::Status status, StatusFileType type)