Skip to main content

crates.io docs.rs CI OpenSSF Scorecard License

Overview

Implements the Embedding Manifests into Unstructured Text section of the C2PA Technical Specification, which carries a C2PA Manifest Store inside a Unicode text stream as a run of non-rendering variation selectors, so provenance survives copy and paste between systems that have no file.

Hello world.<U+FEFF><variation-selector run carrying magic|version|length|manifest>

The specification describes this method as one that should only be used where no other embedding method is feasible. For source code, configuration, and markup, prefer c2pa-structured-text. This crate exists for the case the spec carves out: text with no container.

This crate owns two things:

  1. The frame — encode, embed, locate, and strip the C2PATextManifestWrapper, including the specified deterministic padding.
  2. The hard binding — the exact c2pa.hash.data coverage for unstructured text, with compute and verify.

Signature verification, certificate trust, and assertion validation are not reimplemented here.

Not certified or conformance-tested by the C2PA. It implements the embedding and hard binding as specified.

Zero dependencies by default

[dependencies]
c2pa-unstructured-text = "0.1"

The frame and the binding algorithm pull nothing in. Hashing and NFC are injected through two traits, so a host that already provides them supplies its own:

use c2pa_unstructured_text::hardbinding::{Algorithm, Hasher, Normalizer};

struct HostCrypto;
impl Hasher for HostCrypto {
    fn digest(&self, alg: Algorithm, data: &[u8]) -> Vec<u8> { todo!("call the runtime") }
}
struct HostNfc;
impl Normalizer for HostNfc {
    fn nfc(&self, text: &str) -> String { todo!("call the runtime") }
}

That matters at the edge. A Cloudflare Worker or a browser already has SHA-2 and String.prototype.normalize, so shipping Unicode tables into the bundle is pure waste. Enable hard-binding to get ready-made implementations instead; it adds convenience, never capability.

Embed and extract

use c2pa_unstructured_text::wrapper;

let asset = wrapper::embed("Hello world.", b"manifest-bytes").unwrap();

let found = wrapper::extract(&asset).unwrap();
assert_eq!(found.payload, b"manifest-bytes");
assert_eq!(wrapper::strip(&asset, found.range()).unwrap(), "Hello world.");

The hard binding

The exclusion range covers the U+FEFF marker together with the selector run, including any trailing padding. Offsets are into the text as stored, before normalization. A validator removes the excluded bytes first, normalizes what remains to NFC, then hashes.

# #[cfg(feature = "hard-binding")] {
use c2pa_unstructured_text::hardbinding::{
    compute_data_hash, verify_data_hash, Algorithm, RustCrypto, UnicodeNfc,
};
use c2pa_unstructured_text::wrapper;

let asset = wrapper::embed("Hello world.", b"manifest-bytes").unwrap();
let binding =
    compute_data_hash(&asset, Algorithm::Sha256, &RustCrypto, &UnicodeNfc).unwrap();

assert!(verify_data_hash(&asset, &binding, &RustCrypto, &UnicodeNfc).is_ok());
# }

Normalizing before computing offsets would shift every one of them whenever the stored text is not already NFC, which is why the order is fixed this way.

Deterministic padding

The wrapper's byte length depends on the manifest's byte distribution, since low bytes encode to three UTF-8 bytes and the rest to four. That is circular when the exclusion length has to go inside the manifest being measured. The specification breaks the cycle with a target that depends only on the manifest size, and fixes the padding byte values so compliant generators emit byte-identical wrappers:

use c2pa_unstructured_text::wrapper;

assert_eq!(wrapper::target_length(16), 125);
assert_eq!(wrapper::encode(b"c2pa-manifest-01").unwrap().len(), 114);
// The 11-byte gap decomposes as one 0x00 then two 0x10.
assert_eq!(wrapper::padding(11).unwrap(), vec![0x00, 0x10, 0x10]);
assert_eq!(wrapper::encode_padded(b"c2pa-manifest-01").unwrap().len(), 125);

This is the part of the method implementations most easily diverge on, so it is covered by vectors cross-checked against the C2PA public test corpus.

Locating

The specification defines two failure codes here, and the crate reports both:

outcome code meaning
no wrapper, no candidate (none) the text is unsigned
candidate detected, none decodes manifest.text.corruptedWrapper magic found, frame malformed
more than one valid wrapper manifest.text.multipleWrappers rejected

Only the first means the text carries no provenance, which is what is_no_manifest_located() reports — an integrator needs to tell "carries no provenance" from "carried provenance that was rejected":

use c2pa_unstructured_text::{wrapper, Error};

let err = wrapper::extract("no wrapper here").unwrap_err();
assert_eq!(err, Error::NotFound);
assert!(err.is_no_manifest_located());
assert_eq!(err.code(), None);

A candidate that fails to decode beside a valid wrapper is skipped, not reported: letting stray bytes carrying the magic invalidate an otherwise good wrapper would hand anyone who can append to the text a denial of service.

The specification is in tension here. Placement rule 5 says a validator "may encounter multiple wrappers" and that selection "is governed by the exclusions field", while the status-code section makes more than one valid wrapper a failure. This crate follows the explicit failure code.

Comparison with the structured-text binding

Both crates expose the same shape, so a dispatcher can treat them alike, but coverage differs deliberately.

unstructured (this crate) structured
carrier variation selectors ASCII armour comment
normalization NFC, after exclusion none
exclusion marker + selector run + padding the manifest block line
default deps none none

Features

  • hard-binding — RustCrypto and UnicodeNfc implementations (pulls sha2 and unicode-normalization).
  • checksum-v2 — a v2 frame carrying a truncated hash over the header and payload, so a mangled carrier is rejected rather than decoded to wrong bytes. A WritersLogic extension, not part of the specified frame.

No feature is enabled by default.

Part of a family of single-purpose crates, one per C2PA embedding method. Each is standalone and independently versioned.

Crate Description
c2pa-structured-text Structured text: ASCII-armoured manifest in a comment or front matter
c2pa-html HTML: script and link elements in the document head
c2pa-http HTTP: the c2pa-manifest Link header, with a Tower middleware
c2pa-text-binding Soft binding and content fingerprinting for text assets
c2pa-vtt WebVTT caption and subtitle embedding
c2pa-zip ZIP-based documents: EPUB, DOCX, ODT, OXPS
c2pa-warc WARC web archive embedding (ISO 28500)
c2pa-fonts OpenType/TrueType (SFNT) font embedding
c2pa-ml ML model containers: GGUF, SafeTensors, ONNX
c2pa Official C2PA SDK

Security

Found a vulnerability? Please report it privately — see SECURITY.md.

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Built by WritersLogic

Metadata

Release files for c2pa-unstructured-text 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for c2pa-unstructured-text 0.2.0
File Size Uploaded Provenance Actions
c2pa_unstructured_text-0.2.0.tar.gz 42.2 kB With provenance Details for c2pa_unstructured_text-0.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for c2pa-unstructured-text 0.2.0
File Actions
c2pa_unstructured_text-0.2.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for c2pa_unstructured_text-0.2.0-cp39-abi3-win_amd64.whl
c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 1.6 MB

Release files / c2pa_unstructured_text-0.2.0.tar.gz

Download URL c2pa_unstructured_text-0.2.0.tar.gz
Size 42.2 kB
Tags Source
SHA-256 checksum
How to use checksums
33967c2364444b2a38406b4eaedaa8590465464bf8d03656cff42e2a57583170
BLAKE2b-256 checksum
How to use checksums
d2139573de339a145fb6eb2a84a66b2df9b8285d7cc2ebd8330a4012b3c8d76f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / c2pa_unstructured_text-0.2.0-cp39-abi3-win_amd64.whl

Download URL c2pa_unstructured_text-0.2.0-cp39-abi3-win_amd64.whl
Size 215.3 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
8ed76f30b833ab612555cf87614c14f33eed89ae0d36fb284a31ae83e46b0556
BLAKE2b-256 checksum
How to use checksums
24efc47e03176d4887140dcbbf2363f5568de52a2ff14e24418732b50ec5627d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 348.5 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
286650cc7c02209e82212cf9be5734263e1e164067e1372fd6d92d6a546e7470
BLAKE2b-256 checksum
How to use checksums
c856eb28f730c1b18222678679e0950a0fe61d086aa2e9176cc58622236ced8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL c2pa_unstructured_text-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 342.0 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
52c4ae17816de93e302dbbaed14b4d27a9ffb1882bab0b2174c2cd3385843b47
BLAKE2b-256 checksum
How to use checksums
1252bcc91780909e644c87bb6f534ec2b8e6047bd765f74f7aff17381ab8fdab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Size 313.7 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
130711a72ef1f3dc6aa93c75ebe38ae8b83cf1b437bedb088bc906906f633196
BLAKE2b-256 checksum
How to use checksums
50a595656f39106049b30c48a3adaf42ab76cf2fd9edc30d14753f563619e10d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Release files / c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL c2pa_unstructured_text-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 321.7 kB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
19ab781a74e25177de58ce538aa70dd91e4f21deef0e9c7b5db38c56bb0bfe2d
BLAKE2b-256 checksum
How to use checksums
4928fdb2c67c330acaa71a9e2ae300431cccca634fa89a3dc2f91f57e4dde175
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

Security for c2pa-unstructured-text 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for c2pa_unstructured_text-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

6 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page