Skip to main content

Crate c2pa_zip

Crate c2pa_zip 

Source
Expand description

C2PA Manifest Store embedding and reading for ZIP-based (OCF-style) documents.

Implements the ZIP embedding method from the C2PA Technical Specification, which stores a C2PA Manifest Store as a dedicated entry inside the ZIP archive at ZIP_MANIFEST_PATH (META-INF/content_credential.c2pa). Many document formats are ZIP archives with a fixed internal layout — EPUB, Office Open XML (DOCX/XLSX/PPTX), OpenDocument (ODT/ODS/ODP) and OpenXPS — and all embed through this single transport.

Per the specification, the manifest entry is stored (compression method 0), not encrypted, and its general-purpose bit flag is 0. Embedding appends the entry before the central directory so existing entries keep their byte offsets, then rebuilds the central directory and end-of-central- directory record.

§Binding inputs

A ZIP asset is bound with a c2pa.hash.collection.data assertion carrying one entry per member plus the additional zip_central_directory_hash field, which covers the archive’s own directory so that an entry added after signing cannot leave the manifest valid.

collection_members and central_directory_range supply the byte ranges the specification says to hash. They deliberately do not hash them: locating those ranges is ZIP parsing, which is this crate’s job, while choosing and running a digest is the caller’s, and keeping that split is what lets this crate stay dependency-free.

Manifest construction and signing remain out of scope; use the official c2pa SDK for those.

Structs§

Compliance
The result of a structural check of a ZIP-based document’s C2PA embedding.
Member
A member of the archive, and the byte range of its stored content.

Enums§

Error

Constants§

ZIP_MANIFEST_PATH
Spec-mandated location + filename of the manifest store in a ZIP container.

Functions§

central_directory_range
The byte range covered by zip_central_directory_hash: every central directory header together with the end-of-central-directory record.
collection_members
Every archive member except the C2PA Manifest Store entry, in archive order.
embed_manifest
Embed a C2PA Manifest Store into a ZIP-based document.
read_manifest
Read the embedded C2PA Manifest Store from a ZIP-based document.
remove_manifest
Remove the C2PA Manifest Store from a ZIP-based document, if present, returning the rebuilt archive. A document without a manifest is returned unchanged.
verify
Structurally verify a ZIP-based document’s C2PA embedding.