42 TRACE(
"Entering process_checksum_block(%p, %p)", ctx, entry);
45 size_t read_bytes = 0;
50 size_t payload_pos = 0;
55 FATAL(
"Invalid context or image stream.");
63 FATAL(
"Could not seek to %" PRIu64
" as indicated by index entry...", entry->
offset);
69 TRACE(
"Reading checksum block header at position %" PRIu64, entry->
offset);
75 FATAL(
"Could not read checksums block header, continuing...\n");
82 FATAL(
"Incorrect identifier for checksum block at position %" PRIu64
"\n", entry->
offset);
86 TRACE(
"Allocating %u bytes for checksum block", checksum_header.
length);
87 data = (uint8_t *)malloc(checksum_header.
length);
92 FATAL(
"Could not allocate memory for checksum block, continuing...\n");
99 if(read_bytes != checksum_header.
length)
103 FATAL(
"Could not read checksums block, continuing...\n");
108 TRACE(
"Processing %u checksum entries", checksum_header.
entries);
109 for(j = 0; j < checksum_header.
entries; j++)
113 FATAL(
"Checksum entry %d exceeds block payload size", j);
120 if(payload_pos + checksum_entry->
length > checksum_header.
length)
122 FATAL(
"Checksum payload for entry %d exceeds block payload size", j);
126 switch(checksum_entry->
type)
131 FATAL(
"MD5 checksum entry has invalid length %u", checksum_entry->
length);
135 TRACE(
"Found MD5 checksum");
142 FATAL(
"SHA1 checksum entry has invalid length %u", checksum_entry->
length);
146 TRACE(
"Found SHA1 checksum");
153 FATAL(
"SHA256 checksum entry has invalid length %u", checksum_entry->
length);
157 TRACE(
"Found SHA256 checksum");
162 TRACE(
"Found SpamSum checksum of size %u", checksum_entry->
length);
170 FATAL(
"Could not allocate memory for SpamSum digest");
179 TRACE(
"Unknown checksum type %u, skipping", checksum_entry->
type);
183 payload_pos += checksum_entry->
length;
186 checksum_entry = NULL;
189 TRACE(
"Exiting process_checksum_block()");
void process_checksum_block(aaruformat_context *ctx, const IndexEntry *entry)
Processes a checksum block from the image stream.
On-disk layout definitions for the checksum block (BlockType::ChecksumBlock).
Central runtime context structures for libaaruformat (image state, caches, checksum buffers).
#define MD5_DIGEST_LENGTH
@ ChecksumBlock
Block containing contents checksums.
@ SpamSum
SpamSum (context-triggered piecewise hash).
On‑disk index block header and entry structures (versions 1, 2 and 3).
static int aaruf_fseek(FILE *stream, aaru_off_t offset, int origin)
static aaru_off_t aaruf_ftell(FILE *stream)
#define SHA1_DIGEST_LENGTH
#define SHA256_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).
uint8_t * spamsum
SpamSum fuzzy hash (ASCII), allocated length+1 with trailing 0.
bool hasSha256
True if sha256[] buffer populated.
uint8_t sha1[20]
SHA-1 digest (20 bytes).
uint8_t sha256[32]
SHA-256 digest (32 bytes).
uint8_t md5[16]
MD5 digest (16 bytes).
bool hasSpamSum
True if spamsum pointer allocated and signature read.
bool hasSha1
True if sha1[] buffer populated.
bool hasMd5
True if md5[] buffer populated.
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.
Master context representing an open or in‑creation Aaru image.
Checksums checksums
Whole-image checksums discovered.
FILE * imageStream
Underlying FILE* stream (binary mode).