22 "Cannot use CRC checker without full string formatting");
55 for (i = 0; i < blocks; i++) {
56 stat = f.
read(block_data, bytes_to_read);
62 hash.
update(block_data, bytes_to_read);
66 bytes_to_read = remaining_bytes;
67 if (remaining_bytes > 0) {
68 stat = f.
read(block_data, bytes_to_read);
74 hash.
update(block_data, remaining_bytes);
93 bytes_to_write =
sizeof(checksum);
94 stat = f.
write(reinterpret_cast<U8*>(&checksum), bytes_to_write);
122 stat = f.
read(reinterpret_cast<U8*>(&checksum_from_file), checksum_from_file_size);
123 if (stat !=
Os::File::OP_OK || checksum_from_file_size !=
sizeof(checksum_from_file)) {
145 U32 checksum_from_file;
163 for (i = 0; i < blocks; i++) {
164 stat = f.
read(block_data, bytes_to_read);
170 hash.
update(block_data, static_cast<FwSizeType>(bytes_to_read));
174 bytes_to_read = remaining_bytes;
175 if (remaining_bytes > 0) {
176 stat = f.
read(block_data, bytes_to_read);
182 hash.
update(block_data, remaining_bytes);
188 hash.
final(checksum);
196 if (checksum != checksum_from_file) {
197 expected = checksum_from_file;
202 expected = checksum_from_file;
void update(const void *const data, const FwSizeType len)
PlatformSizeType FwSizeType
static const FwSignedSizeType CRC_FILE_READ_BLOCK
Os::FileInterface::Status open(const char *path, Mode mode)
open file with supplied path and mode
#define FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING
void final(HashBuffer &buffer)
crc_stat_t create_checksum_file(const char *const fname)
crc_stat_t read_crc32_from_file(const char *const fname, U32 &checksum_from_file)
const char * toChar() const
Convert to a C-style char*.
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.
crc_stat_t verify_checksum(const char *const fname, U32 &expected, U32 &actual)
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
uint8_t U8
8-bit unsigned integer
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
Operation was successful.
#define HASH_EXTENSION_STRING
Operation was successful.
FormatStatus
status of string format calls