Skip to main content

Crate c2pa_fonts

Crate c2pa_fonts 

Source
Expand description

C2PA manifest embedding, hard binding, and verification for OpenType/TrueType (SFNT) fonts.

Implements the C2PA font embedding method — storing a C2PA Manifest Store and/or a remote manifest URI in a C2PA SFNT table — together with its c2pa.hash.data hard binding. Embedding re-serializes the font so the table directory, offsets, and checksums (including head.checkSumAdjustment) stay valid.

This crate owns the two format-specific validation steps: locating and extracting the manifest (step 1) and the hard binding (step 5). COSE signature verification, X.509 trust evaluation, and assertion/ingredient validation are delegated to the official c2pa SDK via the optional validation feature. Manifest construction and signing remain the SDK’s job.

The C2PA font table format is preliminary in the C2PA specification and is not yet defined in the OpenType/OFF specifications.

Structs§

C2paTable
A decoded C2PA font table.
Compliance
The result of checking a font’s C2PA embedding for spec compliance.
Exclusion
A byte range excluded from the c2pa.hash.data hard binding.
ManifestSource
What to write into a font’s C2PA table: an embedded Manifest Store, a remote manifest URI, or both.
ReservedFont
A font with a reserved (placeholder) Manifest Store, ready for the hash-then-sign step of the hard-binding flow.
Validation
The outcome of validating a font’s C2PA manifest end to end.

Enums§

Error

Constants§

C2PA_TAG
SFNT table tag identifying the C2PA table.
MAJOR_VERSION
Major version written into new C2PA tables. The format is preliminary in the C2PA specification, so this crate emits version 0.1.
MINOR_VERSION

Functions§

compute_data_hash
Compute the c2pa.hash.data value over the font using the font’s own exclusion ranges, via the same hasher c2pa-rs uses at validation time.
data_hash_exclusions
Byte ranges excluded from the font’s c2pa.hash.data hard binding.
data_hash_ranges
The font’s exclusion ranges as c2pa-rs HashRanges, ready to attach to a c2pa.hash.data assertion.
embed_manifest
Embed a C2PA manifest into a font by inserting (or replacing) its C2PA table.
fill_manifest
Fill a reserved font’s Manifest Store with signed manifest bytes.
read_c2pa_table
Read and decode the C2PA table from a font.
read_manifest
Read the embedded C2PA Manifest Store from a font.
read_manifest_uri
Read the active manifest URI from a font’s C2PA table, if present.
remove_manifest
Remove the C2PA table from a font, if present, returning the re-serialized font.
reserve_manifest
Reserve space for a manifest of reserve_size bytes in a font’s C2PA table, returning the font-with-placeholder and its hard-binding exclusions.
validate
Validate a font’s C2PA manifest end to end.
verify
Verify a font’s C2PA embedding against the specification.
verify_data_hash
Verify that the font’s bytes hash to expected under its exclusion ranges.