README.md (7716B)
1 # C2PA Rust library 2 3 [](https://github.com/contentauth/c2pa-rs/actions/workflows/ci.yml) [](https://crates.io/crates/c2pa) [](https://docs.rs/c2pa/) [](https://codecov.io/gh/contentauth/c2pa-rs) 4 5 <div style={{display: 'none'}}> 6 7 The **[Coalition for Content Provenance and Authenticity](https://c2pa.org)** (C2PA) addresses the prevalence of misleading information online through the development of technical standards for certifying the source and history (or provenance) of media content. Adobe and other contributors created the C2PA Rust library as part of the [Content Authenticity Initiative](https://contentauthenticity.org) and [released it to open source](https://contentauthenticity.org/blog/cai-releases-suite-of-open-source-tools-to-advance-digital-content-provenance) in June, 2022. 8 9 </div> 10 11 ## Key features 12 13 The C2PA Rust library (previously referred to as the "Rust SDK") implements a subset of the [C2PA technical specification](https://c2pa.org/specifications/specifications/1.4/specs/C2PA_Specification.html). 14 15 The library enables a desktop, mobile, or embedded application to: 16 * Create and sign C2PA [claims](https://c2pa.org/specifications/specifications/1.4/specs/C2PA_Specification.html#_claims) and [manifests](https://c2pa.org/specifications/specifications/1.4/specs/C2PA_Specification.html#_manifests). 17 * Embed manifests in certain file formats. 18 * Parse and validate manifests found in certain file formats. 19 20 The library supports several common C2PA [assertions](https://c2pa.org/specifications/specifications/1.4/specs/C2PA_Specification.html#_c2pa_standard_assertions) and [hard bindings](https://c2pa.org/specifications/specifications/1.4/specs/C2PA_Specification.html#_hard_bindings). 21 22 ## State of the project 23 24 This is a beta release (version 0.x.x) of the project. The minor version number (0.x.0) is incremented when there are breaking API changes, which may happen frequently. 25 26 ### Contributions and feedback 27 28 We welcome contributions to this project. For information on contributing, providing feedback, and about ongoing work, see [Contributing](https://github.com/contentauth/c2pa-js/blob/main/CONTRIBUTING.md). 29 30 ## Requirements 31 32 The library requires **Rust version 1.74.0** or newer. 33 34 ### Supported platforms 35 36 The library has been tested on the following operating systems: 37 38 * Windows (Intel only) 39 * MacOS (Intel and Apple silicon) 40 * Ubuntu Linux (64-bit Intel and ARM v8) 41 * WebAssembly (Wasm) 42 43 ## Supported file formats 44 45 | Extensions | MIME type | 46 | ------------- | --------------------------------------------------- | 47 | `avi` | `video/msvideo`, `video/avi`, `application-msvideo` | 48 | `avif` | `image/avif` | 49 | `c2pa` | `application/x-c2pa-manifest-store` | 50 | `dng` | `image/x-adobe-dng` | 51 | `heic` | `image/heic` | 52 | `heif` | `image/heif` | 53 | `jpg`, `jpeg` | `image/jpeg` | 54 | `m4a` | `audio/mp4` | 55 | `mp4` | `video/mp4`, `application/mp4` | 56 | `mov` | `video/quicktime` | 57 | `png` | `image/png` | 58 | `svg` | `image/svg+xml` | 59 | `tif`,`tiff` | `image/tiff` | 60 | `wav` | `audio/wav` | 61 | `webp` | `image/webp` | 62 63 ## Usage 64 65 Add this to your `Cargo.toml`: 66 67 ```toml 68 [dependencies] 69 c2pa = "0.32.2" 70 ``` 71 72 If you want to read or write a manifest file, add the `file_io` dependency to your `Cargo.toml`. 73 The `add_thumbnails` feature will generate thumbnails for JPEG and PNG files. 74 For example: 75 ``` 76 c2pa = { version = "0.25.0", features = ["file_io", "add_thumbnails"] } 77 ``` 78 79 NOTE: If you are building for WASM, omit the `file_io` dependency. 80 81 ## Crate features 82 83 The Rust library crate provides: 84 85 * `file_io` enables manifest generation, signing via OpenSSL, and embedding manifests in various file formats. 86 * `add_thumbnails` will generate thumbnails automatically for JPEG and PNG files. (no longer included with `file_io`) 87 * `serialize_thumbnails` includes binary thumbnail data in the [Serde](https://serde.rs/) serialization output. 88 * `xmp_write` enables updating XMP on embed with the `dcterms:provenance` field. (Requires [xmp_toolkit](https://crates.io/crates/xmp_toolkit).) 89 * `no_interleaved_io` forces fully-synchronous I/O; otherwise, the library uses threaded I/O for some operations to improve performance. 90 * `fetch_remote_manifests` enables the verification step to retrieve externally referenced manifest stores. External manifests are only fetched if there is no embedded manifest store and no locally adjacent .c2pa manifest store file of the same name. 91 * `json_schema` is used by `make schema` to produce a JSON schema document that represents the `ManifestStore` data structures. 92 * `psxxx_ocsp_stapling_experimental` this is an demonstration feature that will attempt to fetch the OCSP data from the OCSP responders listed in the manifest signing certificate. The response becomes part of the manifest and is used to prove the certificate was not revoked at the time of signing. This is only implemented for PS256, PS384 and PS512 signatures and is intended as a demonstration. 93 94 95 ## Example code 96 97 The [sdk/examples](https://github.com/contentauth/c2pa-rs/tree/main/sdk/examples) directory contains some minimal example code. The [client/client.rs](https://github.com/contentauth/c2pa-rs/blob/main/sdk/examples/client/client.rs) is the most instructive and provides and example of reading the contents of a manifest store, recursively displaying nested manifests. 98 99 ## License 100 101 The `c2pa` crate is distributed under the terms of both the [MIT license](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-MIT) and the [Apache License (Version 2.0)](https://github.com/contentauth/c2pa-rs/blob/main/LICENSE-APACHE). 102 103 Some components and dependent crates are licensed under different terms; please check the license terms for each crate and component for details. 104 105 ## Nightly builds 106 107 In most cases, you should depend on this crate as published via [crates.io](https://crates.io/crates/c2pa). 108 109 The Adobe team produces nightly snapshots of this crate via a `nightly` branch, which we use for testing the impact of pending changes to upstream dependencies. 110 111 You may wish to use these builds for your own testing ahead of our releases, you may include the library via the following `Cargo.toml` entry: 112 113 ```toml 114 c2pa = { git = "https://github.com/contentauth/c2pa-rs.git", branch = "nightly", features = [...]} 115 ``` 116 117 Commits in this branch have a modified `sdk/Cargo.toml` entry which includes a version number similar to the following: 118 119 ```toml 120 version = "0.25.3-nightly+2023-08-28-2f33ab3" 121 ``` 122 123 Please note that there is no formal support for code from a nightly release, but if you become aware of any issues, we would appreciate a bug report including this version number. 124 125 ## Changelog 126 127 Refer to the [CHANGELOG](https://github.com/contentauth/c2pa-rs/blob/main/CHANGELOG.md) for detailed changes derived from Git commit history. 128