c2pa-rs

A fork of https://github.com/contentauth/c2pa-rs/
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/c2pa-rs.git
Log | Files | Refs | README

commit 5049455b848f0976db0fc7ec99e4833c2899cb5a
parent cf041601e27ce7aed2ddc805744e60d28320c502
Author: Gavin  Peacock <gpeacock@adobe.com>
Date:   Thu, 13 Jul 2023 15:02:36 -0700

(MINOR) User, UserCbor and Uuid assertions removed from SDK (#141)

* Hide User assertions from public SDK
Diffstat:
MREADME.md | 20+++++++++++++-------
Msdk/src/assertions/mod.rs | 7++++---
Msdk/src/assertions/user_cbor.rs | 4----
Msdk/src/lib.rs | 13++++++++-----
Msdk/src/manifest.rs | 19++++++++++---------
5 files changed, 35 insertions(+), 28 deletions(-)

diff --git a/README.md b/README.md @@ -61,12 +61,14 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -c2pa = "0.24.0" +c2pa = "0.25.0" ``` -If you want to read or write a manifest file, add the `file_io` dependency to your `Cargo.toml`. For example: +If you want to read or write a manifest file, add the `file_io` dependency to your `Cargo.toml`. +The `add_thumbnails` feature will generate thumbnails for JPEG and PNG files. + For example: ``` -c2pa = { version = "0.19.0", features = ["file_io"] } +c2pa = { version = "0.25.0", features = ["file_io", "add_thumbnails"] } ``` NOTE: If you are building for WASM, omit the `file_io` dependency. @@ -76,6 +78,7 @@ NOTE: If you are building for WASM, omit the `file_io` dependency. The Rust SDK crate provides: * `file_io` enables manifest generation, signing via OpenSSL, and embedding manifests in various file formats. +* `add_thumbnails` will generate thumbnails automatically for JPEG and PNG files. (no longer included with `file_io`) * `serialize_thumbnails` includes binary thumbnail data in the [Serde](https://serde.rs/) serialization output. * `xmp_write` enables updating XMP on embed with the `dcterms:provenance` field. (Requires [xmp_toolkit](https://crates.io/crates/xmp_toolkit).) * `no_interleaved_io` forces fully-synchronous I/O; otherwise, the SDK uses threaded I/O for some operations to improve performance. @@ -94,14 +97,17 @@ This section gives a highlight of noteworthy changes Refer to the [CHANGELOG](https://github.com/contentauth/c2pa-rs/blob/main/CHANGELOG.md) for detailed Git changes + ## 0.25.0 _14 July 2023_ -* (important!) the add_thumbnails feature is no longer tied to file_io, so you will need to specify it or thumbnails will not be generated. -* DataHash and BoxHash SDK support (generates a signed manifest ready to write into a file without writing to the file) +* (important!) the `add_thumbnails` feature is no longer tied to `file_io`, so you will need to specify it or thumbnails will not be generated. +* removed `User` and `UserCbor` assertions from public API. They were not generating correct manifest data. +* use `manifest_add_labeled_assertion` instead - see docs on `manifest.embed` for an example. +* `DataHash` and `BoxHash` SDK support (generates a signed manifest ready to write into a file without writing to the file) * The SDK will no longer remove duplicate ingredients based on hash -* make_test_images updated to fix issue 195, actions without required ingredients +* `make_test_images` updated to fix issue 195, actions without required ingredients * updated the test fixtures generated by make_test_images -* Expose CAIRead and CAIWrite traits required by some SDK calls. +* Expose `CAIRead` and `CAIWrite` traits required by some SDK calls. * Bug fix for certain BMFF formats (AVIF) that causes images to be unreadable ## 0.24.0 diff --git a/sdk/src/assertions/mod.rs b/sdk/src/assertions/mod.rs @@ -50,10 +50,11 @@ mod thumbnail; pub(crate) use thumbnail::Thumbnail; mod user; -pub use user::User; +pub(crate) use user::User; mod user_cbor; -pub use user_cbor::UserCbor; +pub(crate) use user_cbor::UserCbor; mod uuid_assertion; -pub use uuid_assertion::Uuid; +#[allow(unused_imports)] +pub(crate) use uuid_assertion::Uuid; diff --git a/sdk/src/assertions/user_cbor.rs b/sdk/src/assertions/user_cbor.rs @@ -33,10 +33,6 @@ impl UserCbor { cbor_data: data, } } - - pub fn data(&self) -> &[u8] { - &self.cbor_data - } } impl AssertionBase for UserCbor { diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs @@ -54,15 +54,18 @@ //! # use c2pa::Result; //! use std::path::PathBuf; //! -//! use c2pa::{assertions::User, create_signer, Manifest, SigningAlg}; +//! use c2pa::{create_signer, Manifest, SigningAlg}; +//! use serde::Serialize; //! use tempfile::tempdir; //! +//! #[derive(Serialize)] +//! struct Test { +//! my_tag: usize, +//! } +//! //! # fn main() -> Result<()> { //! let mut manifest = Manifest::new("my_app".to_owned()); -//! manifest.add_assertion(&User::new( -//! "org.contentauth.mylabel", -//! r#"{"my_tag":"Anything I want"}"#, -//! ))?; +//! manifest.add_labeled_assertion("org.contentauth.test", &Test { my_tag: 42 })?; //! //! let source = PathBuf::from("tests/fixtures/C.jpg"); //! let dir = tempdir()?; diff --git a/sdk/src/manifest.rs b/sdk/src/manifest.rs @@ -964,16 +964,17 @@ impl Manifest { /// /// ``` /// # use c2pa::Result; - /// use c2pa::{assertions::User, create_signer, Manifest, SigningAlg}; + /// use c2pa::{create_signer, Manifest, SigningAlg}; + /// use serde::Serialize; + /// + /// #[derive(Serialize)] + /// struct Test { + /// my_tag: usize, + /// } + /// /// # fn main() -> Result<()> { /// let mut manifest = Manifest::new("my_app".to_owned()); - /// manifest.add_assertion(&User::new( - /// "org.contentauth.mylabel", - /// r#"{"my_tag":"Anything I want"}"#, - /// ))?; - /// - /// let source = "tests/fixtures/C.jpg"; - /// let dest = "../target/test_file.jpg"; + /// manifest.add_labeled_assertion("org.contentauth.test", &Test { my_tag: 42 })?; /// /// // Create a PS256 signer using certs and public key files. /// let signcert_path = "tests/fixtures/certs/ps256.pub"; @@ -981,7 +982,7 @@ impl Manifest { /// let signer = create_signer::from_files(signcert_path, pkey_path, SigningAlg::Ps256, None)?; /// /// // Embed a manifest using the signer. - /// manifest.embed(&source, &dest, &*signer)?; + /// manifest.embed("tests/fixtures/C.jpg", "../target/test_file.jpg", &*signer)?; /// # Ok(()) /// # } /// ```