libaaruformat 1.0 Aaru Data Preservation Suite - Format Library

Loading...
Searching...
No Matches
checksum.h File Reference

On-disk layout definitions for the checksum block (BlockType::ChecksumBlock). More...

`#include <stdint.h>`

Go to the source code of this file.

## Data Structures
struct | ChecksumHeader
| Header that precedes the sequence of checksum entries for a checksum block. More...
struct | ChecksumEntry
| Per-checksum metadata immediately followed by the digest / signature bytes. More...

## Typedefs
typedef struct ChecksumHeader | ChecksumHeader
typedef struct ChecksumEntry | ChecksumEntry

## Detailed Description

On-disk layout definitions for the checksum block (BlockType::ChecksumBlock).

A checksum block stores one or more whole-image (user data) checksums. For optical media the user data definition follows the format's raw sector rules (e.g. 2352-byte raw sector when available).

Binary layout (all integers are little-endian, structure is packed):

+---------------------------—+----------------------------—+ | Field | Size (bytes) | +==============================+===============================+ | ChecksumHeader | sizeof(ChecksumHeader)=9 | | identifier | 4 (BlockType::ChecksumBlock) | | length | 4 (payload bytes that follow)| | entries | 1 (number of checksum entries)| +---------------------------—+----------------------------—+ | Repeated for each entry: | | ChecksumEntry | sizeof(ChecksumEntry)=5 | | type | 1 (ChecksumAlgorithm) | | length | 4 (digest length) | | digest bytes | length | +---------------------------—+----------------------------—+

Thus, the payload size (ChecksumHeader.length) MUST equal the sum over all entries of: sizeof(ChecksumEntry) + entry.length.

Typical digest lengths:

- Md5: 16 bytes
- Sha1: 20 bytes
- Sha256: 32 bytes
- SpamSum: variable length ASCII, NOT null-terminated on disk (a terminating '\0' may be appended in memory).

Warning
  The structures are packed; never rely on host compiler default padding or directly casting from a buffer without ensuring correct endianness if porting to big-endian systems (current implementation assumes LE).

See also
  BlockType
  ChecksumAlgorithm

Definition in file checksum.h.

## Typedef Documentation

## ◆ ChecksumEntry

typedef struct ChecksumEntry ChecksumEntry

## ◆ ChecksumHeader

typedef struct ChecksumHeader ChecksumHeader