Expand description
Rust library for reading and writing Expert Witness Format forensic images.
ewf_image provides direct Rust APIs for working with Expert Witness Format
images. It can open physical, logical, SMART, and EWF2 segment families,
expose metadata and stored hashes, read the logical media stream, walk
logical single-file catalogs, and create EWF output. An optional acquisition
CLI is available; a filesystem mount layer is not currently implemented.
§Terminology
Logical media size is the decoded byte length exposed by Image::media_size
and ImageInfo::logical_size. Segment set size is the total byte length of
the opened EWF container files, as reported by Image::segment_set_size.
Chunks are the stored allocation units used by EWF tables. Logical EWF
images can also contain a single-file catalog, where each entry describes a
file-like object stored inside the image.
§Supported container families
- EWF1 physical
.E01/ EVF images. - X-Ways AES-128/AES-256 encrypted EWF1 images.
- EWF1 logical
.L01/ LVF images. - EWF1 SMART
.S01images. - EWF2 physical
.Ex01images. - EWF2 logical
.Lx01images.
§Reading
use std::io::Read;
fn main() -> ewf_image::Result<()> {
let image = ewf_image::Image::open("case.E01")?;
let info = image.info();
println!("{:?}: {} bytes", info.format, info.logical_size);
println!("segments: {}", image.number_of_segments());
let mut sector = vec![0; 512];
image.cursor().read_exact(&mut sector)?;
let mut later_sector = vec![0; 512];
image.read_at(&mut later_sector, 4096)?;
Ok(())
}Password-protected X-Ways EWF1 images use the same read APIs after a password-aware open:
fn main() -> ewf_image::Result<()> {
let password = ewf_image::EwfPassword::utf8("operator-supplied-password");
let image = ewf_image::Image::open_with_password("case.E01", &password)?;
println!("{:?}", image.encryption_info());
Ok(())
}§Metadata and hashes
fn main() -> ewf_image::Result<()> {
let image = ewf_image::Image::open("case.E01")?;
if let Some(case_number) = image.header_value("case_number") {
println!("case: {case_number}");
}
if let Some(md5) = image.hash_value("MD5") {
println!("stored MD5: {md5}");
}
#[cfg(feature = "verify")]
{
let verification = image.verify()?;
println!("MD5 match: {:?}", verification.md5_match);
println!("SHA1 match: {:?}", verification.sha1_match);
}
Ok(())
}§Writing
use std::fs::File;
fn main() -> ewf_image::Result<()> {
let mut input = File::open("disk.raw")?;
let mut options = ewf_image::WriteOptions::default();
options.format = ewf_image::WriteFormat::Ewf2Physical;
options.compression = ewf_image::WriteCompression::Zlib;
options.metadata.set_header_value("case_number", "CASE-001");
let mut writer = ewf_image::EwfWriter::create("case.Ex01", options)?;
std::io::copy(&mut input, &mut writer)?;
writer.finish()?;
Ok(())
}§Streaming acquisition
AcquisitionWriter seals physical E01 segments as input arrives and can
resume sealed checkpoints without rewriting them. It requires a known,
sector-aligned source size and a filesystem supporting hard links.
use std::fs::File;
use std::ops::ControlFlow;
use ewf_image::{AcquisitionOptions, AcquisitionReadOptions, AcquisitionStatus, AcquisitionWriter};
fn continue_acquisition(source_identity: [u8; 32]) -> ewf_image::Result<()> {
let mut input = File::open("disk.raw")?;
let options = AcquisitionOptions::new(input.metadata()?.len());
// Use create instead of resume for the first acquisition session.
// The caller must bind source_identity to a stable source snapshot.
let mut writer = AcquisitionWriter::resume("case.E01", &options, source_identity)?;
let outcome = writer.acquire_with_progress(
&mut input, &AcquisitionReadOptions::default(), |progress| {
println!("{} accepted; {} checkpointed", progress.bytes_written, progress.checkpoint_bytes);
// Return Break(()) when the application's cancellation flag is set.
ControlFlow::Continue(())
}
)?;
if outcome.status == AcquisitionStatus::Complete {
writer.finish()?;
}
Ok(())
}§Feature flags
verifyis enabled by default and addsImage::verify()plusVerifyResultfor streamed MD5/SHA1 verification. Stored hash parsing, EWF2 section integrity checks, and writer hash support are available without this feature.external-fixturesenables ignored integration tests that require local EWF corpora and external EWF tools. It does not change library behavior.fuzzingexposes the logical catalog parser to the isolated fuzz workspace.parallelenables multiple decompression workers for verification and analysis. It impliesverify; scans remain single-threaded by default.serdeenables serialization of analysis, verification, recovery, and section-summary results.
§Analysis and recovery
Image::sections exposes descriptor locations. Image::open_sources
accepts SegmentSource backings with independent positioned reads.
With verify, verify_with_options computes SHA256 and compares external
references; analyze returns typed findings and explicit media coverage.
EwfRecovery separately recovers physical raw/zlib EWF1 data with
provenance and exclusive creation of output files.
§Limitations
X-Ways encrypted EWF1 reading is supported. Encrypted EWF2 images are detected and rejected, and encrypted writing is not implemented. Secondary/shadow target mirroring is supported by the file-backed writer. Base-plus-overlay delta/shadow images are not implemented.
Structs§
- Acquisition
Checkpoint - Snapshot of a stopped acquisition.
- Acquisition
Error - Acquisition error range recorded in image metadata.
- Acquisition
Operation Progress - Progress for one validation, rehash, or publication phase.
- Acquisition
Options - Configuration for a new, single-destination physical E01 acquisition. The source size must be known, nonzero, and a multiple of the sector size.
- Acquisition
Outcome - Source-acquisition outcome. Publication remains an explicit
finishstep. - Acquisition
Progress - Source progress delivered synchronously on the acquiring thread.
- Acquisition
Read Options - Source-reading policy; it can be changed between calls or after resume. Previously substituted sectors and their provenance are never rewritten.
- Acquisition
Writer - Append-only physical E01 writer with resumable sealed segments.
- Compression
Flags - Compression flags recorded in EWF metadata.
- Compression
Values - Compression level and flags recorded together.
- Computed
Hashes - Hashes over every logical media byte, excluding final-chunk padding.
- Data
Chunk - Decoded logical data chunk.
- Encoded
Data Chunk - Encoded data chunk as stored in an EWF segment.
- Encryption
Info - Non-secret encryption status for an opened EWF image.
- EwfMetadata
- Parsed case and acquisition metadata.
- EwfPassword
- Password bytes supplied for one encrypted EWF image open attempt.
- EwfRecovery
- Read-only recovery plan for physical, unencrypted raw/zlib EWF1 segments.
- EwfWriter
- Incremental EWF writer.
- Hash
Comparison - One comparison; external references never replace embedded references.
- Image
- Opened EWF image and logical media reader.
- Image
Cursor - Seekable cursor over an
Imagelogical media stream. - Image
Info - Parsed summary of an opened EWF image.
- Integrity
Finding - One finding with optional source and logical locations.
- Integrity
Report - Bounded integrity findings plus explicit scan coverage.
- Logical
Entry Metadata - Caller-supplied metadata for a logical acquisition entry.
- Logical
Write Progress - Progress within the file currently being added.
- Logical
Writer - Builds an L01/Lx01 catalog and file hashes while accepting file streams.
- Media
Flags - Media flags recorded for an image.
- Media
Info - Parsed media geometry and storage metadata.
- Memory
Extent - Memory acquisition extent recorded in pages.
- Open
Options - Options that control how an image is opened and read.
- Reader
Cache Info - Configured and observed payload bytes for one shared EWF reader cache set.
- Reader
Statistics - Cumulative performance counters for one shared EWF image reader.
- Recovery
Notice - Structural damage or missing metadata encountered while locating recoverable data.
- Recovery
Options - Controls recovery output size, suspect-data handling, and report retention.
- Recovery
Progress - Streaming recovery progress. The initial event has no last status.
- Recovery
Range - Consecutive chunks sharing the same recovery outcome.
- Recovery
Report - Completed recovery accounting. Recovery does not establish image authenticity.
- Section
Info - A section’s location in its original segment. Payloads are not retained. These are the descriptors accepted during opening, not a fresh integrity check.
- Sector
Range - Inclusive start plus count sector range.
- Segment
File Version - EWF2 segment file version.
- Segment
Source - A bounded view of a positioned backing, memory buffer, or file.
- Sequential
Options - Settings for a known-length, append-only EWF1 physical or EWF2 write.
- Sequential
Writer - Streams EWF1 physical or EWF2 payload into staged native segments without a full raw spool.
- Single
File Attribute - Extended attribute for a logical single-file entry.
- Single
File Cursor - Seekable cursor over one logical single-file catalog entry.
- Single
File Entry - Entry in a logical single-file catalog.
- Single
File Extent - Data extent for a logical single-file entry.
- Single
File Permission - Access-control entry for a logical single-file entry.
- Single
File Permission Group - Access-control group for logical single-file entries.
- Single
File Progress - Progress over one file’s bytes, including sparse zeroes.
- Single
File Source - Source record for logical single-file metadata.
- Single
File Subject - Subject record for logical single-file metadata.
- Single
File Verification - Completed file-level verification; never certifies the whole container.
- Single
Files AuxTables - Preserved auxiliary EWF2 single-file tables.
- Single
Files Info - Logical single-file catalog metadata.
- Stored
Hashes - Stored hash values parsed from an image.
- Verification
Report - Completed media verification. Mismatches are results, not I/O errors.
- Verify
Options - Options shared by verification and media integrity analysis.
- Verify
Progress - Progress delivered on the calling thread, in logical order.
- Verify
Result - Result of streamed logical media hash verification.
- Write
Compression Values - Compression settings for writer output.
- Write
Hashes - Hash values configured for writer output.
- Write
Media Profile - Media type and acquisition flags configured for writer output.
- Write
Options - Configuration used to create an
EwfWriter. - Write
Result - Result returned after finalizing writer output.
Enums§
- Acquisition
Operation Phase - Long-running checkpoint or publication operation currently in progress.
- Acquisition
Status - Why a source acquisition call returned successfully.
- Chunk
Cache Capacity - Capacity policy for the decoded-chunk cache.
- Compression
Level - Compression level recorded in EWF metadata.
- Compression
Method - Compression method recorded for stored chunks.
- Data
Chunk Encoding - Encoding used for a data chunk payload.
- Encryption
Method - Encryption method applied to an opened EWF image.
- EwfError
- Error type used by EWF readers, writers, and probe helpers.
- Format
- Top-level EWF container generation.
- Format
Profile - Producer/profile inferred from EWF metadata and section layout.
- Hash
Algorithm - Digest algorithm used in a comparison.
- Hash
Reference - Origin of a reference digest.
- Header
Codepage - Codepage used for EWF1 textual header values.
- Header
Date Format - Formatting applied when returning parsed EWF header date values.
- Integrity
Finding Kind - Stable categories for findings; diagnostic text is not a machine interface.
- Integrity
Severity - Severity of a reported integrity condition.
- Media
Scan Status - Coverage of the logical media pass, separate from the findings’ severity.
- Media
Type - Media type recorded for an image.
- Open
Strictness - Strictness used while opening an image.
- Recovery
Status - Provenance of one recovered logical chunk.
- Section
Kind - On-disk section identifier, preserving unknown producer-defined types.
- Single
File Entry Type - Type of a logical single-file catalog entry.
- Unreadable
Sector Policy - Treatment of a sector that remains unreadable after its retries.
- Write
Compression - Compression method for writer output.
- Write
Compression Level - Compression level for writer output.
- Write
Format - Output EWF format selected for writing.
Constants§
- SINGLE_
FILE_ PATH_ SEPARATOR - Path separator used by EWF2 logical single-file catalogs.
Traits§
- Segment
Read At - A stable-length, thread-safe segment backing with independent positioned reads.
- Segment
Reader - Reader type accepted by
Image::open_readers.
Functions§
- analyze_
path - Opens strictly, then scans media and redundant tables.
- analyze_
path_ with_ password - Password-aware counterpart to
analyze_path. Password failures are reported without exposing password or key material. - analyze_
path_ with_ progress - Opens strictly and analyzes with cooperative media-scan cancellation.
- analyze_
path_ with_ progress_ and_ password - Password-aware counterpart to
analyze_path_with_progress. - check_
file_ corruption - Returns whether a single segment appears corrupt based on structural checks.
- check_
file_ encryption - Returns whether a file appears to be an encrypted EWF segment.
- check_
file_ signature - Returns whether a file starts with a recognized EWF segment signature.
- check_
segment_ files_ corruption - Returns whether a segment set appears corrupt based on structural checks.
- check_
segment_ files_ encryption - Returns whether any segment in a segment set appears to be encrypted.
Type Aliases§
- Result
- Result type returned by fallible
ewf_imageAPIs.