41 TRACE(
"Entering process_checksum_block(%p, %p)", ctx, entry);
44 size_t read_bytes = 0;
49 size_t payload_pos = 0;
54 FATAL(
"Invalid context or image stream.");
62 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
68 TRACE(
"Reading checksum block header at position %" PRIu64, entry->
offset);
74 FATAL(
"Could not read checksums block header, continuing...\n");
81 FATAL(
"Incorrect identifier for checksum block at position %" PRIu64
"\n", entry->
offset);
85 TRACE(
"Allocating %u bytes for checksum block", checksum_header.
length);
86 data = (uint8_t *)malloc(checksum_header.
length);
91 FATAL(
"Could not allocate memory for checksum block, continuing...\n");
98 if(read_bytes != checksum_header.
length)
102 FATAL(
"Could not read checksums block, continuing...\n");
107 TRACE(
"Processing %u checksum entries", checksum_header.
entries);
108 for(j = 0; j < checksum_header.
entries; j++)
112 FATAL(
"Checksum entry %d exceeds block payload size", j);
119 if(payload_pos + checksum_entry->
length > checksum_header.
length)
121 FATAL(
"Checksum payload for entry %d exceeds block payload size", j);
125 switch(checksum_entry->
type)
130 FATAL(
"MD5 checksum entry has invalid length %u", checksum_entry->
length);
134 TRACE(
"Found MD5 checksum");
141 FATAL(
"SHA1 checksum entry has invalid length %u", checksum_entry->
length);
145 TRACE(
"Found SHA1 checksum");
152 FATAL(
"SHA256 checksum entry has invalid length %u", checksum_entry->
length);
156 TRACE(
"Found SHA256 checksum");
161 TRACE(
"Found SpamSum checksum of size %u", checksum_entry->
length);
169 FATAL(
"Could not allocate memory for SpamSum digest");
178 TRACE(
"Unknown checksum type %u, skipping", checksum_entry->
type);
182 payload_pos += checksum_entry->
length;
185 checksum_entry = NULL;
188 TRACE(
"Exiting process_checksum_block()");
Central runtime context structures for libaaruformat (image state, caches, checksum buffers).
#define MD5_DIGEST_LENGTH
Per-checksum metadata immediately followed by the digest / signature bytes.
uint32_t length
Length in bytes of the digest that immediately follows this structure.
uint8_t type
Algorithm used (value from ChecksumAlgorithm).
Single index entry describing a block's type, (optional) data classification, and file offset.
uint64_t offset
Absolute byte offset in the image where the referenced block header begins.