Documentation
¶
Index ¶
- Constants
- Variables
- func SegmentPaths(path string) ([]string, error)
- type BadRange
- type ChecksumPolicy
- type MissingSegmentsError
- type Option
- type Reader
- func Open(source io.ReaderAt) (Reader, error)
- func OpenPath(path string) (Reader, error)
- func OpenPathWithOptions(path string, opts ...Option) (Reader, error)
- func OpenSegments(sources []io.ReaderAt) (Reader, error)
- func OpenSegmentsWithOptions(sources []io.ReaderAt, opts ...Option) (Reader, error)
- func OpenWithOptions(source io.ReaderAt, opts ...Option) (Reader, error)
- type SegmentError
- type VerifyResult
- type Writerdeprecated
Constants ¶
const ( // ChecksumWarn decodes the image anyway and reports failures in // Metadata().ChunkTablesInvalid. ChecksumWarn = reader.ChecksumWarn // ChecksumIgnore suppresses checksum accounting entirely. ChecksumIgnore = reader.ChecksumIgnore // ChecksumStrict refuses to open an image with an unverifiable chunk table. ChecksumStrict = reader.ChecksumStrict )
Checksum policies. The default is ChecksumWarn.
const ( Version = "0.3.0" // Author information Author = "libewf contributors" )
Version information
Variables ¶
var ( // ErrNotImplemented marks API endpoints that are intentionally absent. ErrNotImplemented = ewferr.ErrNotImplemented // ErrUnsupportedFormat indicates an unrecognised or undecodable format. ErrUnsupportedFormat = ewferr.ErrUnsupportedFormat // ErrCorruptImage indicates structural damage that prevents decoding. ErrCorruptImage = ewferr.ErrCorruptImage // ErrInvalidOffset indicates a negative or unusable ReadAt offset. ErrInvalidOffset = ewferr.ErrInvalidOffset // ErrEncrypted indicates the image is encrypted and no key was supplied. ErrEncrypted = ewferr.ErrEncrypted // ErrMissingSegment indicates a gap in the supplied segment numbering. ErrMissingSegment = ewferr.ErrMissingSegment // ErrIncompleteSegmentSet indicates trailing segments were not supplied. ErrIncompleteSegmentSet = ewferr.ErrIncompleteSegmentSet // ErrChecksumMismatch indicates checksum validation failed under // ChecksumStrict. ErrChecksumMismatch = ewferr.ErrChecksumMismatch )
Sentinel errors returned by this package. Compare with errors.Is.
Functions ¶
func SegmentPaths ¶ added in v0.2.1
SegmentPaths returns the paths of every segment that belongs with path, in segment order, without opening any of them.
It exists so that a caller can record which files an image was decoded from. An examiner's report that names the evidence is worth more than one that says a set was complete, and the same ordering is what OpenPath itself uses.
Types ¶
type BadRange ¶
type BadRange struct {
// Offset is the byte offset of the span within the decoded device.
Offset int64
// Length is the length of the span in bytes.
Length int64
// Err is the error reported for the span.
Err string
}
BadRange records a span of the device that could not be decoded.
type ChecksumPolicy ¶
type ChecksumPolicy = reader.ChecksumPolicy
ChecksumPolicy selects what happens when stored checksum validation fails.
type MissingSegmentsError ¶ added in v0.2.1
type MissingSegmentsError = ewferr.MissingSegmentsError
MissingSegmentsError lists the segment numbers absent from a set discovered by OpenPath, and the files they would be named. See ewferr.MissingSegmentsError.
type Option ¶
Option configures how an image is opened.
func AllowIncompleteSegmentSet ¶
func AllowIncompleteSegmentSet() Option
AllowIncompleteSegmentSet permits opening a segment set that does not begin at segment 1 or whose final segment carries no "done" section.
Such a set decodes only part of the device: Size reports the full device size declared by the volume section, but reads past the supplied data return io.EOF. Use it for metadata inspection and triage of damaged evidence, never for content that will be hashed or carved.
func WithChecksumPolicy ¶
func WithChecksumPolicy(p ChecksumPolicy) Option
WithChecksumPolicy selects the response to a chunk table that fails its stored Adler-32 checksum.
The default, ChecksumWarn, decodes the image and records the failure, because damaged evidence should still yield whatever is readable. Pass ChecksumStrict when unverified chunk offsets are worse than no image at all; Open then fails with ErrChecksumMismatch.
func WithChunkCache ¶
WithChunkCache sets how many decoded chunks the reader keeps cached.
A chunk is the smallest decodable unit of an EWF image, so a caller reading 512 bytes at a time would otherwise re-decompress the whole enclosing chunk on every call. Filesystem parsers read exactly like that, which is why caching is on by default.
Pass a positive depth to override the default of 16, or a negative value to disable caching when memory matters more than throughput. Memory use is the depth multiplied by the image's chunk size, capped internally so an unusual chunk size cannot turn a small depth into a large allocation.
type Reader ¶
type Reader interface {
io.ReaderAt
// Size returns the logical size of the decoded device in bytes.
Size() int64
// SectorSize returns the logical sector size in bytes, or 0 if unknown.
SectorSize() int
// Metadata returns parsed image metadata.
Metadata() metadata.Info
// Close releases resources held by the reader. The caller retains
// ownership of the io.ReaderAt sources and must close them separately.
//
// A Reader from OpenPath is the exception: it opened its own files, so
// its Close closes them too.
Close() error
}
Reader exposes read operations over an EWF image presented as one contiguous decoded device.
Implementations are safe for concurrent use provided the underlying io.ReaderAt sources are.
func Open ¶
Open prepares an EWF reader from a random-access source.
The source must be a complete single-segment image. To open a multi-segment set, pass every segment to OpenSegments, or its first file to OpenPath and let the rest be discovered.
func OpenPath ¶ added in v0.2.1
OpenPath prepares an EWF reader from a path to one segment file, discovering the rest of the set on disk.
This is the constructor most callers want. Open and OpenSegments take io.ReaderAt because the library should not assume evidence lives on a local filesystem, but the common case is that it does, and every such caller was otherwise obliged to reimplement the EWF naming progression — which runs .E01 to .E99 and then continues .EAA, not .E100 — before they could open an image at all.
path may name any numbered member of the set, not only the first: the set is identified by the stem and family of the name and then enumerated from segment 1, so an image opened by its .E03 still decodes from its .E01. A path whose extension names no EWF family is opened as a single file.
Ownership ¶
Unlike every other constructor in this package, the returned Reader owns the files it opened and its Close closes them. It has to: the caller never sees the handles, so nobody else can. Callers needing the concrete reader's methods can reach it with an Unwrap() Reader type assertion.
Completeness ¶
A hole in the numbering fails with a *MissingSegmentsError naming the files that were not found. A set that stops short of its true end cannot be detected from the directory — nothing there records how many segments the acquisition wrote — and is caught instead when the segments are read, as ErrIncompleteSegmentSet. Both are suppressed by AllowIncompleteSegmentSet.
func OpenPathWithOptions ¶ added in v0.2.1
OpenPathWithOptions prepares an EWF reader from a segment path with options. See OpenPath for how the segment set is discovered and who owns the files.
func OpenSegments ¶
OpenSegments prepares an EWF reader from a full segment set. Segments may be supplied in any order; they are ordered by segment number before decoding.
The set must be complete. A gap in the numbering, or a final segment that does not terminate with a "done" section, is an error: decoding a partial set would silently present a truncated or misaligned device.
func OpenSegmentsWithOptions ¶
OpenSegmentsWithOptions prepares an EWF reader from a segment set with options.
type SegmentError ¶
type SegmentError = ewferr.SegmentError
SegmentError identifies which segment in a set failed. See ewferr.SegmentError.
type VerifyResult ¶
type VerifyResult struct {
// Size is the logical device size that was hashed.
Size int64
// BytesHashed counts the bytes fed to the digests, including any zero
// fill substituted for unreadable spans.
BytesHashed int64
// HasStoredMD5 reports whether the image records an acquisition MD5.
HasStoredMD5 bool
// StoredMD5 is the digest recorded at acquisition time.
StoredMD5 []byte
// ComputedMD5 is the digest of the decoded device.
ComputedMD5 []byte
// MD5Match is true when a stored MD5 exists and matches.
MD5Match bool
// HasStoredSHA1 reports whether the image records an acquisition SHA-1.
HasStoredSHA1 bool
// StoredSHA1 is the digest recorded at acquisition time.
StoredSHA1 []byte
// ComputedSHA1 is the digest of the decoded device.
ComputedSHA1 []byte
// SHA1Match is true when a stored SHA-1 exists and matches.
SHA1Match bool
// BadRanges lists spans that could not be decoded. Each was replaced with
// zero bytes so that hashing could continue, which means any entry here
// invalidates the computed digests.
BadRanges []BadRange
}
VerifyResult reports the outcome of recomputing acquisition digests over a decoded image.
func Verify ¶
func Verify(ctx context.Context, r Reader) (*VerifyResult, error)
Verify recomputes MD5 and SHA-1 over the whole decoded device and compares them against the digests stored in the image at acquisition time.
This is the strongest self-contained integrity check available for an EWF image: the stored digests were computed by the acquisition tool from the original device, so reproducing them from the decoded stream confirms both that the media is intact and that it was decoded correctly.
Spans that fail to decode are replaced with zero bytes, recorded in BadRanges, and hashing continues, so a damaged image still yields a report of how much is unreadable. Any such span makes the digests meaningless; check OK or BadRanges before trusting a mismatch as evidence of tampering.
Verify reads the entire device and is therefore O(image size). It honours ctx cancellation between reads.
func (*VerifyResult) OK ¶
func (v *VerifyResult) OK() bool
OK reports whether every stored digest was reproduced and no span failed to decode. An image that stores no digests can never be OK, because there is nothing to verify against.
type Writer
deprecated
Writer exposes high-level write operations for EWF images.
Deprecated: libewf is a read-only library by design. No write path is planned; Create always returns ErrNotImplemented.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package ewferr defines the sentinel error values returned by libewf.
|
Package ewferr defines the sentinel error values returned by libewf. |
|
examples
|
|
|
open
command
|
|
|
readat
command
|
|
|
internal
|
|
|
corpus
Package corpus describes the golden-image corpus used to validate the reader against images produced by real acquisition tools.
|
Package corpus describes the golden-image corpus used to validate the reader against images produced by real acquisition tools. |
|
segname
Package segname decodes and generates the file names of an EWF segment set.
|
Package segname decodes and generates the file names of an EWF segment set. |
|
tools
|
|
|
mkcorpus
command
Command mkcorpus builds the golden-image corpus that validates the reader against images written by real acquisition tools.
|
Command mkcorpus builds the golden-image corpus that validates the reader against images written by real acquisition tools. |