simple-c2pa

This is a fork of https://gitlab.com/guardianproject/proofmode/simple-c2pa
git clone git://archive.git.mtrnord.blog/mtrnords-photography-manager/simple-c2pa.git
Log | Files | Refs | README | LICENSE

commit ec6d88f9feeaec9ae054843b92ea87e5fe36447b
parent 3ce89fdd55a7f0c4ccbe7601be453317189288fd
Author: MTRNord <mtrnord1@gmail.com>
Date:   Sun, 23 Jun 2024 15:15:49 +0200

Cleanup and reduce clones and other unnecessary copies that might happen.

Diffstat:
MCargo.lock | 1714+++++++++++++++++++++++++++++++++++++++++++++----------------------------------
MCargo.toml | 8+-------
DPackage.swift | 28----------------------------
Dandroid/.gitlab-ci.yml | 28----------------------------
Dandroid/project/.gitignore | 16----------------
Dandroid/project/build.gradle.kts | 6------
Dandroid/project/gradle.properties | 23-----------------------
Dandroid/project/gradle/wrapper/gradle-wrapper.jar | 0
Dandroid/project/gradle/wrapper/gradle-wrapper.properties | 6------
Dandroid/project/gradlew | 185-------------------------------------------------------------------------------
Dandroid/project/gradlew.bat | 89-------------------------------------------------------------------------------
Dandroid/project/settings.gradle.kts | 17-----------------
Dandroid/project/simple_c2pa/build.gradle.kts | 67-------------------------------------------------------------------
Dandroid/project/simple_c2pa/consumer-rules.pro | 0
Dandroid/project/simple_c2pa/proguard-rules.pro | 25-------------------------
Dandroid/project/simple_c2pa/src/main/AndroidManifest.xml | 4----
Dapple/.gitlab-ci.yml | 58----------------------------------------------------------
Dapple/src/SimpleC2PA/SimpleC2PA.swift | 1837-------------------------------------------------------------------------------
Msrc/assertions.rs | 197++++++++++++++++++++++++++++++++++---------------------------------------------
Dsrc/bin/uniffi-bindgen.rs | 5-----
Msrc/certificates.rs | 169+++++++++++++++++++++++++------------------------------------------------------
Msrc/common.rs | 33+++++++++++++++------------------
Msrc/content_credentials.rs | 58++++++++++++++++++++++++++++------------------------------
Msrc/lib.rs | 10+++++-----
Mtests/examples.rs | 9++++++---
Duniffi.toml | 5-----
26 files changed, 1170 insertions(+), 3427 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -3,6 +3,15 @@ version = 3 [[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -24,60 +33,6 @@ dependencies = [ ] [[package]] -name = "anstream" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fde6067df7359f2d6335ec1a50c1f8f825801687d10da0cc4c6b08e3f6afd15" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" -dependencies = [ - "windows-sys 0.52.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" -dependencies = [ - "anstyle", - "windows-sys 0.52.0", -] - -[[package]] -name = "anyhow" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" - -[[package]] name = "arrayref" version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -90,45 +45,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] -name = "askama" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" -dependencies = [ - "askama_derive", - "askama_escape", -] - -[[package]] -name = "askama_derive" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ccf09143e56923c12e027b83a9553210a3c58322ed8419a53461b14a4dccd85" -dependencies = [ - "askama_parser", - "basic-toml", - "mime", - "mime_guess", - "proc-macro2", - "quote", - "serde", - "syn 2.0.48", -] - -[[package]] -name = "askama_escape" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" - -[[package]] -name = "askama_parser" -version = "0.2.0" +name = "arrayvec" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "262eb9cf7be51269c5f2951eeda9ccd14d6934e437457f47b4f066bf55a6770d" -dependencies = [ - "nom", -] +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "asn1-rs" @@ -177,18 +97,18 @@ checksum = "86bc01d15ca67ec7653924057aa97c30de62d06a24e6834387eba6c72c8318e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", ] [[package]] name = "async-trait" -version = "0.1.77" +version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" +checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", ] [[package]] @@ -199,9 +119,24 @@ checksum = "132573478eb9ff973c6f75d0ed425ac12da77d266506483345f46743ecc83a98" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "backtrace" +version = "0.3.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide 0.7.4", + "object", + "rustc-demangle", +] [[package]] name = "base-x" @@ -222,19 +157,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] -name = "base64ct" -version = "1.6.0" +name = "base64" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] -name = "basic-toml" -version = "0.1.8" +name = "base64ct" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5" -dependencies = [ - "serde", -] +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" [[package]] name = "bcder" @@ -247,25 +179,41 @@ dependencies = [ ] [[package]] -name = "bincode" -version = "1.3.3" +name = "bitflags" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" dependencies = [ "serde", ] [[package]] -name = "bitflags" -version = "1.3.2" +name = "bitvec" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] [[package]] -name = "bitflags" -version = "2.4.2" +name = "bitvec-nom2" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "4863ce31b7ff8812568eaffe956024c824d845a1f9f08c329706166c357cae53" +dependencies = [ + "bitvec", + "nom", +] [[package]] name = "blake2b_simd" @@ -274,7 +222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -285,7 +233,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e461a7034e85b211a4acb57ee2e6730b32912b06c08cc242243c39fc21ae6a2" dependencies = [ "arrayref", - "arrayvec", + "arrayvec 0.5.2", "constant_time_eq", ] @@ -316,15 +264,15 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bumpalo" -version = "3.14.0" +version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -343,15 +291,13 @@ dependencies = [ [[package]] name = "bytes" -version = "1.5.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" [[package]] name = "c2pa" -version = "0.28.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b922d6791a54d8d95645ecd08df7eaeb3bd134103efccb4421b94377bb6f2ff" +version = "0.32.2" dependencies = [ "asn1-rs", "async-generic", @@ -364,9 +310,11 @@ dependencies = [ "bytes", "chrono", "ciborium", + "config", "console_log", "conv", "coset", + "ed25519-dalek", "extfmt", "fast-xml", "getrandom", @@ -378,17 +326,20 @@ dependencies = [ "jfifdump", "js-sys", "lazy_static", - "log", + "memchr", "mp4", "multibase", "multihash", "openssl", - "openssl-sys", + "pem 3.0.4", "png_pong", "rand", + "rand_chacha", "range-set", + "rasn", + "rasn-ocsp", + "rasn-pkix", "riff", - "ring 0.16.20", "rsa", "serde", "serde-transcode", @@ -397,12 +348,13 @@ dependencies = [ "serde_cbor", "serde_derive", "serde_json", + "serde_with", "sha2 0.10.8", "spki 0.6.0", "tempfile", "thiserror", + "tracing", "treeline", - "twoway", "ureq", "url", "uuid", @@ -411,48 +363,14 @@ dependencies = [ "web-sys", "x509-certificate", "x509-parser", -] - -[[package]] -name = "camino" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed8ef69d8518a5dda55c07425450b58a4e1946f4951eab6d7191ee86c2443d" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", - "thiserror", + "zip", ] [[package]] name = "cc" -version = "1.0.83" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" [[package]] name = "cfg-if" @@ -462,9 +380,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", @@ -472,14 +390,14 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets", ] [[package]] name = "ciborium" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" dependencies = [ "ciborium-io", "ciborium-ll", @@ -488,71 +406,42 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" [[package]] name = "ciborium-ll" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" dependencies = [ "ciborium-io", - "half", -] - -[[package]] -name = "clap" -version = "4.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" -dependencies = [ - "clap_builder", - "clap_derive", + "half 2.4.1", ] [[package]] -name = "clap_builder" -version = "4.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.48", -] - -[[package]] -name = "clap_lex" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - -[[package]] name = "color_quant" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] -name = "colorchoice" -version = "1.0.0" +name = "config" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" +dependencies = [ + "json5", + "lazy_static", + "nom", + "pathdiff", + "ron", + "rust-ini", + "serde", + "serde_json", + "toml", +] [[package]] name = "console_log" @@ -578,6 +467,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + +[[package]] +name = "const_panic" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6051f239ecec86fde3410901ab7860d458d160371533842974fc61f96d15879b" + +[[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -600,9 +515,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "coset" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c7f688ee58418b8614848a05bf392cc622f92451e79998c131b9d22c91abd9" +checksum = "ff8aad850c1f86daa47e812913051eb5a26c4d9fb4242a89178bf99b946e4e3c" dependencies = [ "ciborium", "ciborium-io", @@ -619,14 +534,45 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] [[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] name = "crypto-bigint" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -647,22 +593,84 @@ dependencies = [ ] [[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.67", +] + +[[package]] name = "custom_derive" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" [[package]] +name = "darling" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.67", +] + +[[package]] +name = "darling_macro" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.67", +] + +[[package]] name = "data-encoding" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" +checksum = "e8566979429cf69b49a5c740c60791108e86440e8be149bbea4fe54d2c32d6e2" [[package]] name = "data-encoding-macro" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" +checksum = "f1559b6cba622276d6d63706db152618eeb15b89b3e4041446b05876e352e639" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -670,9 +678,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" +checksum = "332d754c0af53bc87c108fed664d121ecf59207ec4196041f04d6ab9002ad33f" dependencies = [ "data-encoding", "syn 1.0.109", @@ -700,9 +708,9 @@ dependencies = [ [[package]] name = "der" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid 0.9.6", "zeroize", @@ -729,6 +737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", + "serde", ] [[package]] @@ -752,23 +761,74 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", +] + +[[package]] +name = "dlv-list" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" +dependencies = [ + "const-random", ] [[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8 0.10.2", + "signature", +] + +[[package]] +name = "ed25519-dalek" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2 0.10.8", + "subtle", + "zeroize", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] name = "errno" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] @@ -788,9 +848,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" [[package]] name = "fdeflate" @@ -802,16 +862,28 @@ dependencies = [ ] [[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] name = "flate2" -version = "1.0.28" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" dependencies = [ "crc32fast", - "miniz_oxide 0.7.1", + "miniz_oxide 0.7.4", ] [[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] name = "foreign-types" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -836,13 +908,10 @@ dependencies = [ ] [[package]] -name = "fs-err" -version = "2.11.0" +name = "funty" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" -dependencies = [ - "autocfg", -] +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "generic-array" @@ -856,9 +925,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.12" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -868,27 +937,44 @@ dependencies = [ ] [[package]] -name = "glob" -version = "0.3.1" +name = "gimli" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" [[package]] -name = "goblin" -version = "0.6.1" +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + +[[package]] +name = "half" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d6b4de4a8eb6c46a8c77e1d3be942cb9a8bf073c22374578e5ba4b08ed0ff68" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" dependencies = [ - "log", - "plain", - "scroll", + "cfg-if", + "crunchy", ] [[package]] -name = "half" -version = "1.8.2" +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" @@ -904,9 +990,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -931,12 +1017,18 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ba0a11a3cf6f08d58a5629531bdb4e7c3b8b595e9812a31a7058b1176c4631e" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "byteorder", "flate2", ] [[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] name = "idna" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -948,9 +1040,9 @@ dependencies = [ [[package]] name = "image" -version = "0.24.8" +version = "0.24.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -972,10 +1064,32 @@ dependencies = [ ] [[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", + "serde", +] + +[[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", "js-sys", @@ -984,19 +1098,25 @@ dependencies = [ ] [[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "jfifdump" -version = "0.4.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b56eea9f2724de66d5f44cbc4b45e716a32c83a581d163cee2b767ddc220426" -dependencies = [ - "json", -] +checksum = "326647c83ea8fb213e58a272f11d4569611277d8730f9905a59fba9d30b12c05" [[package]] name = "jpeg-decoder" @@ -1006,18 +1126,29 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] -name = "json" -version = "0.12.4" +name = "json5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd" +checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" +dependencies = [ + "pest", + "pest_derive", + "serde", +] + +[[package]] +name = "jzon" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ab85f84ca42c5ec520e6f3c9966ba1fd62909ce260f8837e248857d2560509" [[package]] name = "keccak" @@ -1029,19 +1160,39 @@ dependencies = [ ] [[package]] +name = "konst" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50a0ba6de5f7af397afff922f22c149ff605c766cd3269cf6c1cd5e466dbe3b9" +dependencies = [ + "const_panic", + "konst_kernel", + "typewit", +] + +[[package]] +name = "konst_kernel" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0a455a1719220fd6adf756088e1c69a85bf14b6a9e24537a5cc04f503edb2b" +dependencies = [ + "typewit", +] + +[[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] [[package]] name = "libc" -version = "0.2.152" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libm" @@ -1051,37 +1202,21 @@ checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] -name = "mime_guess" -version = "2.0.4" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" -dependencies = [ - "mime", - "unicase", -] +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minimal-lexical" @@ -1091,16 +1226,6 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - -[[package]] -name = "miniz_oxide" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" @@ -1110,9 +1235,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", "simd-adler32", @@ -1170,11 +1295,10 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" dependencies = [ - "autocfg", "num-integer", "num-traits", ] @@ -1197,20 +1321,25 @@ dependencies = [ ] [[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] [[package]] name = "num-iter" -version = "0.1.43" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" dependencies = [ "autocfg", "num-integer", @@ -1219,11 +1348,10 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" dependencies = [ - "autocfg", "num-bigint", "num-integer", "num-traits", @@ -1232,15 +1360,24 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", "libm", ] [[package]] +name = "object" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434" +dependencies = [ + "memchr", +] + +[[package]] name = "oid-registry" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1256,24 +1393,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] -name = "oneshot-uniffi" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c548d5c78976f6955d72d0ced18c48ca07030f7a1d4024529fedd7c1c01b29c" - -[[package]] name = "opaque-debug" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.57" +version = "0.10.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "cfg-if", "foreign-types", "libc", @@ -1290,23 +1421,23 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", ] [[package]] name = "openssl-src" -version = "111.28.1+1.1.1w" +version = "300.3.1+3.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf7e82ffd6d3d6e6524216a0bfd85509f68b5b28354e8e7800057e44cefa9b4" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.92" +version = "0.9.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db7e971c2c2bba161b2d2fdf37080177eff520b3bc044787c7f1f5f9e78d869b" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", @@ -1316,10 +1447,20 @@ dependencies = [ ] [[package]] -name = "paste" -version = "1.0.14" +name = "ordered-multimap" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" +checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" +dependencies = [ + "dlv-list", + "hashbrown 0.13.2", +] + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "pem" @@ -1331,6 +1472,16 @@ dependencies = [ ] [[package]] +name = "pem" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" +dependencies = [ + "base64 0.22.1", + "serde", +] + +[[package]] name = "pem-rfc7468" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1346,6 +1497,57 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] +name = "pest" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "560131c633294438da9f7c4b08189194b20946c8274c6b9e38881a7874dc8ee8" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26293c9193fbca7b1a3bf9b79dc1e388e927e6cacaa78b4a3ab705a1d3d41459" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.67", +] + +[[package]] +name = "pest_meta" +version = "2.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a240022f37c361ec1878d646fc5b7d7c4d28d5946e1a80ad5a7a4f4ca0bdcd" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.8", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] name = "pix" version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1358,7 +1560,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a78f66c04ccc83dd4486fd46c33896f4e17b24a7a3a6400dedc48ed0ddd72320" dependencies = [ "der 0.5.1", - "pkcs8", + "pkcs8 0.8.0", "zeroize", ] @@ -1374,38 +1576,43 @@ dependencies = [ ] [[package]] -name = "pkg-config" -version = "0.3.29" +name = "pkcs8" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.9", + "spki 0.7.3", +] [[package]] -name = "plain" -version = "0.2.3" +name = "pkg-config" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "png" -version = "0.17.11" +version = "0.17.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f6c3c3e617595665b8ea2ff95a86066be38fb121ff920a9c0eb282abcd1da5a" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" dependencies = [ "bitflags 1.3.2", "crc32fast", "fdeflate", "flate2", - "miniz_oxide 0.7.1", + "miniz_oxide 0.7.4", ] [[package]] name = "png_pong" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32b76c1da19406fed18e81972b9015a775447532647b04a8949135916d67778f" +checksum = "3daa5a7330d36033a4d7239a85a65a78214a29c1a5478f1f9a9dde10fe9afffd" dependencies = [ - "miniz_oxide 0.4.4", + "miniz_oxide 0.7.4", "pix", + "simd-adler32", ] [[package]] @@ -1422,23 +1629,29 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.76" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95fc56cda0b5c3325f5fbbd7ff9fda9e02bb00bb3dac51252d2f1bfa1cb8cc8c" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1479,12 +1692,80 @@ dependencies = [ ] [[package]] -name = "redox_syscall" -version = "0.4.1" +name = "rasn" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "cf9b0d03fbc7d2dcfdd35086c43ce30ac5ff62ed7eff4397e4f4f2995a2b0e2a" dependencies = [ - "bitflags 1.3.2", + "arrayvec 0.7.4", + "bitvec", + "bitvec-nom2", + "bytes", + "chrono", + "either", + "jzon", + "konst", + "nom", + "num-bigint", + "num-integer", + "num-traits", + "once_cell", + "rasn-derive", + "snafu", +] + +[[package]] +name = "rasn-derive" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbaf7105cd254b632f4732fbcc243ce750cef87d8335826125ef6df5733b5a0c" +dependencies = [ + "either", + "itertools", + "proc-macro2", + "quote", + "rayon", + "syn 1.0.109", + "uuid", +] + +[[package]] +name = "rasn-ocsp" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f67b70624980f4e802b2b449d715c7de24279cf6e9ef39380cd82dac780327" +dependencies = [ + "rasn", + "rasn-pkix", +] + +[[package]] +name = "rasn-pkix" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65a71ceddda846a11d6805fb25e79294b8ada36bdbd75a709bc293c21670b52e" +dependencies = [ + "rasn", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", ] [[package]] @@ -1510,16 +1791,29 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" dependencies = [ "cc", + "cfg-if", "getrandom", "libc", "spin 0.9.8", "untrusted 0.9.0", - "windows-sys 0.48.0", + "windows-sys", +] + +[[package]] +name = "ron" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +dependencies = [ + "base64 0.21.7", + "bitflags 2.5.0", + "serde", + "serde_derive", ] [[package]] @@ -1535,7 +1829,7 @@ dependencies = [ "num-iter", "num-traits", "pkcs1", - "pkcs8", + "pkcs8 0.8.0", "rand_core", "smallvec", "subtle", @@ -1543,6 +1837,31 @@ dependencies = [ ] [[package]] +name = "rust-ini" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" +dependencies = [ + "cfg-if", + "ordered-multimap", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] name = "rusticata-macros" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1553,89 +1872,65 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.30" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "rustls" -version = "0.21.10" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", - "ring 0.17.7", + "ring 0.17.8", + "rustls-pki-types", "rustls-webpki", - "sct", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", + "subtle", + "zeroize", ] [[package]] -name = "ryu" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" - -[[package]] -name = "scroll" -version = "0.11.0" +name = "rustls-pki-types" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04c565b551bafbef4157586fa379538366e4385d42082f255bfd96e4fe8519da" -dependencies = [ - "scroll_derive", -] +checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] -name = "scroll_derive" -version = "0.11.1" +name = "rustls-webpki" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.48", + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", ] [[package]] -name = "sct" -version = "0.7.1" +name = "ryu" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "semver" -version = "1.0.21" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" -dependencies = [ - "serde", -] +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" dependencies = [ "serde_derive", ] @@ -1675,33 +1970,73 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ - "half", + "half 1.8.3", "serde", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.203" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ + "indexmap 2.2.6", "itoa", "ryu", "serde", ] [[package]] +name = "serde_spanned" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_with" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.2.6", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.67", +] + +[[package]] name = "sha-1" version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1770,27 +2105,43 @@ name = "simple-c2pa" version = "0.0.14" dependencies = [ "c2pa", - "log", "openssl", - "ring 0.17.7", + "ring 0.17.8", "serde", "serde_json", "tempfile", "thiserror", - "uniffi", + "tracing", ] [[package]] -name = "siphasher" -version = "0.3.11" +name = "smallvec" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] -name = "smallvec" -version = "1.12.0" +name = "snafu" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4de37ad025c587a29e8f3f5605c00f70b98715ef90b9061a815b9e59e9042d6" +dependencies = [ + "backtrace", + "doc-comment", + "snafu-derive", +] + +[[package]] +name = "snafu-derive" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2593d31f82ead8df961d8bd23a64c2ccf2eb5dd34b0a34bfb4dd54011c72009e" +checksum = "990079665f075b699031e9c08fd3ab99be5029b96f3b78dc0709e8f77e4efebf" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] [[package]] name = "spin" @@ -1830,26 +2181,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" dependencies = [ "base64ct", - "der 0.7.8", + "der 0.7.9", ] [[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] name = "strsim" -version = "0.10.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5" [[package]] name = "syn" @@ -1864,9 +2209,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90" dependencies = [ "proc-macro2", "quote", @@ -1886,46 +2231,52 @@ dependencies = [ ] [[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] name = "tempfile" -version = "3.9.0" +version = "3.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" +checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", "rustix", - "windows-sys 0.52.0", + "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.56" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", ] [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -1940,14 +2291,24 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] [[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] name = "tinyvec" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1964,208 +2325,128 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.5.11" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", ] [[package]] -name = "treeline" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" - -[[package]] -name = "twoway" -version = "0.2.2" +name = "toml_datetime" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c57ffb460d7c24cd6eda43694110189030a3d1dfe418416d9468fd1c1d290b47" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ - "memchr", - "unchecked-index", + "serde", ] [[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "unchecked-index" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeba86d422ce181a719445e51872fa30f1f7413b62becb52e95ec91aa262d85c" - -[[package]] -name = "unicase" -version = "2.7.0" +name = "toml_edit" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ - "version_check", + "indexmap 2.2.6", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", ] [[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - -[[package]] -name = "unicode-ident" -version = "1.0.12" +name = "tracing" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] [[package]] -name = "unicode-normalization" -version = "0.1.22" +name = "tracing-attributes" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "tinyvec", + "proc-macro2", + "quote", + "syn 2.0.67", ] [[package]] -name = "unicode-xid" -version = "0.2.4" +name = "tracing-core" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] [[package]] -name = "uniffi" -version = "0.25.3" +name = "treeline" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f" -dependencies = [ - "anyhow", - "camino", - "clap", - "uniffi_bindgen", - "uniffi_build", - "uniffi_core", - "uniffi_macros", -] +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] -name = "uniffi_bindgen" -version = "0.25.3" +name = "typenum" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd992f2929a053829d5875af1eff2ee3d7a7001cb3b9a46cc7895f2caede6940" -dependencies = [ - "anyhow", - "askama", - "camino", - "cargo_metadata", - "clap", - "fs-err", - "glob", - "goblin", - "heck", - "once_cell", - "paste", - "serde", - "toml", - "uniffi_meta", - "uniffi_testing", - "uniffi_udl", -] +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] -name = "uniffi_build" -version = "0.25.3" +name = "typewit" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9" +checksum = "c6fb9ae6a3cafaf0a5d14c2302ca525f9ae8e07a0f0e6949de88d882c37a6e24" dependencies = [ - "anyhow", - "camino", - "uniffi_bindgen", + "typewit_proc_macros", ] [[package]] -name = "uniffi_checksum_derive" -version = "0.25.3" +name = "typewit_proc_macros" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55137c122f712d9330fd985d66fa61bdc381752e89c35708c13ce63049a3002c" -dependencies = [ - "quote", - "syn 2.0.48", -] +checksum = "e36a83ea2b3c704935a01b4642946aadd445cea40b10935e3f8bd8052b8193d6" [[package]] -name = "uniffi_core" -version = "0.25.3" +name = "ucd-trie" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b" -dependencies = [ - "anyhow", - "bytes", - "camino", - "log", - "once_cell", - "oneshot-uniffi", - "paste", - "static_assertions", -] +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" [[package]] -name = "uniffi_macros" -version = "0.25.3" +name = "unicode-bidi" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4" -dependencies = [ - "bincode", - "camino", - "fs-err", - "once_cell", - "proc-macro2", - "quote", - "serde", - "syn 2.0.48", - "toml", - "uniffi_build", - "uniffi_meta", -] +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] -name = "uniffi_meta" -version = "0.25.3" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71dc8573a7b1ac4b71643d6da34888273ebfc03440c525121f1b3634ad3417a2" -dependencies = [ - "anyhow", - "bytes", - "siphasher", - "uniffi_checksum_derive", -] +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "uniffi_testing" -version = "0.25.3" +name = "unicode-normalization" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "118448debffcb676ddbe8c5305fb933ab7e0123753e659a71dc4a693f8d9f23c" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" dependencies = [ - "anyhow", - "camino", - "cargo_metadata", - "fs-err", - "once_cell", + "tinyvec", ] [[package]] -name = "uniffi_udl" -version = "0.25.3" +name = "unicode-xid" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3" -dependencies = [ - "anyhow", - "uniffi_meta", - "uniffi_testing", - "weedle2", -] +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "unsigned-varint" @@ -2187,15 +2468,16 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.1" +version = "2.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" +checksum = "d11a831e3c0b56e438a28308e7c810799e3c118417f342d30ecec080105395cd" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "flate2", "log", "once_cell", "rustls", + "rustls-pki-types", "rustls-webpki", "url", "webpki-roots", @@ -2213,12 +2495,6 @@ dependencies = [ ] [[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] name = "uuid" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2249,9 +2525,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2259,24 +2535,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ "cfg-if", "js-sys", @@ -2286,9 +2562,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2296,28 +2572,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.67", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ "js-sys", "wasm-bindgen", @@ -2325,17 +2601,11 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" - -[[package]] -name = "weedle2" -version = "4.0.0" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e79c5206e1f43a2306fd64bdb95025ee4228960f2e6c5a8b173f3caaf807741" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ - "nom", + "rustls-pki-types", ] [[package]] @@ -2366,16 +2636,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-sys" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" -dependencies = [ - "windows-targets 0.48.5", + "windows-targets", ] [[package]] @@ -2384,122 +2645,90 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", + "windows-targets", ] [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" [[package]] -name = "windows_i686_gnu" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" +name = "windows_i686_gnullvm" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.5" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.0" +name = "windows_x86_64_msvc" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" +name = "winnow" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +dependencies = [ + "memchr", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.0" +name = "wyz" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] [[package]] name = "x509-certificate" @@ -2510,9 +2739,9 @@ dependencies = [ "bcder", "bytes", "chrono", - "der 0.7.8", + "der 0.7.9", "hex", - "pem", + "pem 1.1.1", "ring 0.16.20", "signature", "spki 0.7.3", @@ -2538,6 +2767,17 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zip" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", +] diff --git a/Cargo.toml b/Cargo.toml @@ -6,13 +6,12 @@ edition = "2021" [dependencies] c2pa = { version = "0.32.1", features = ["file_io", "add_thumbnails"], path = "/run/media/marcel/1ac60e61-e5e2-4157-9a7a-830801a3fb0b/projects/c2pa-rs/sdk" } openssl = "0.10.48" -log = "0.4.20" ring = "0.17.7" serde = "1.0.195" serde_json = "1.0.111" tempfile = "3.9.0" thiserror = "1.0.56" -uniffi = { version = "0.25.3", features = ["build", "cli"] } +tracing = "0.1.40" [profile.release] strip = true @@ -23,8 +22,3 @@ panic = "abort" [lib] name = "simple_c2pa" -crate-type = ["lib", "staticlib", "cdylib"] - -[[bin]] -name = "uniffi-bindgen" -path = "src/bin/uniffi-bindgen.rs" diff --git a/Package.swift b/Package.swift @@ -1,28 +0,0 @@ -// swift-tools-version:5.5 -import PackageDescription - -let package = Package( - name: "SimpleC2PA", - platforms: [ - .iOS(.v15), - ], - products: [ - .library( - name: "SimpleC2PA", - targets: ["SimpleC2PA"] - ), - ], - dependencies: [], - targets: [ - .binaryTarget( - name: "SimpleC2PAFramework", - url: "https://gitlab.com/api/v4/projects/51891540/packages/generic/simple_c2pa/0.0.13/SimpleC2PA.xcframework.zip", - checksum: "ac39eddc4c76ea4afaca559c888cc48f0dd5e05d93138c6b9c55a26488a25e9f" - ), - .target( - name: "SimpleC2PA", - dependencies: [ "SimpleC2PAFramework" ], - path: "apple/src" - ), - ] -) diff --git a/android/.gitlab-ci.yml b/android/.gitlab-ci.yml @@ -1,28 +0,0 @@ -stages: - - build - - upload - - release - -build_android: - only: - - main - - develop - - tags - tags: - - proofmode-debian - stage: build - script: - - cargo make android-build - artifacts: - paths: - - ./out/android/ - -publish_android: - image: mobiledevops/android-sdk-image:33.0.2 - only: - - tags - stage: release - script: - - cp -r out/android/* android/project/simple_c2pa/src/main/ - - ls -al android/project/simple_c2pa/src/main/ - - cd android/project && ./gradlew clean assembleRelease && ./gradlew publish diff --git a/android/project/.gitignore b/android/project/.gitignore @@ -1,16 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/caches -/.idea/libraries -/.idea/modules.xml -/.idea/workspace.xml -/.idea/navEditor.xml -/.idea/assetWizardSettings.xml -.DS_Store -**/build/ -/captures -.externalNativeBuild -.cxx -local.properties -.idea diff --git a/android/project/build.gradle.kts b/android/project/build.gradle.kts @@ -1,6 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. -plugins { - id("org.jetbrains.kotlin.android") version "1.9.0" apply false - id("com.android.library") version "8.1.3" apply false -} - diff --git a/android/project/gradle.properties b/android/project/gradle.properties @@ -1,23 +0,0 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official -# Enables namespacing of each library's R class so that its R class includes only the -# resources declared in the library itself and none from the library's dependencies, -# thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true diff --git a/android/project/gradle/wrapper/gradle-wrapper.jar b/android/project/gradle/wrapper/gradle-wrapper.jar Binary files differ. diff --git a/android/project/gradle/wrapper/gradle-wrapper.properties b/android/project/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +0,0 @@ -#Thu Nov 16 17:31:21 CET 2023 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/android/project/gradlew b/android/project/gradlew @@ -1,185 +0,0 @@ -#!/usr/bin/env sh - -# -# Copyright 2015 the original author or authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=`expr $i + 1` - done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -exec "$JAVACMD" "$@" diff --git a/android/project/gradlew.bat b/android/project/gradlew.bat @@ -1,89 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/project/settings.gradle.kts b/android/project/settings.gradle.kts @@ -1,17 +0,0 @@ -pluginManagement { - repositories { - google() - mavenCentral() - gradlePluginPortal() - } -} -dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) - repositories { - google() - mavenCentral() - } -} - -rootProject.name = "simple_c2pa" -include(":simple_c2pa") diff --git a/android/project/simple_c2pa/build.gradle.kts b/android/project/simple_c2pa/build.gradle.kts @@ -1,67 +0,0 @@ -import org.gradle.api.publish.maven.MavenPublication - -plugins { - id("com.android.library") - id("org.jetbrains.kotlin.android") - `maven-publish` -} - -android { - namespace = "info.guardianproject.simple_c2pa" - compileSdk = 33 - - defaultConfig { - minSdk = 21 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles("consumer-rules.pro") - } - - buildTypes { - release { - isMinifyEnabled = false - proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), - "proguard-rules.pro" - ) - } - } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - } -} - -dependencies { - implementation("androidx.core:core-ktx:1.9.0") - implementation("androidx.appcompat:appcompat:1.6.1") - implementation("com.google.android.material:material:1.8.0") - testImplementation("junit:junit:4.13.2") - androidTestImplementation("androidx.test.ext:junit:1.1.5") - androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") - implementation("net.java.dev.jna:jna:5.13.0@aar") -} - -publishing { - publications { - create<MavenPublication>("release") { - artifact("$buildDir/outputs/aar/${project.name}-release.aar") - groupId = "info.guardianproject" - artifactId = "simple_c2pa" - version = System.getenv("CI_COMMIT_TAG") as String? - } - } - repositories { - maven { - url = uri("https://gitlab.com/api/v4/projects/51891540/packages/maven") - credentials { - this.username = System.getenv("MAVEN_USERNAME") as String? - this.password = System.getenv("MAVEN_PASSWORD") as String? - } - } - } -} - diff --git a/android/project/simple_c2pa/consumer-rules.pro b/android/project/simple_c2pa/consumer-rules.pro diff --git a/android/project/simple_c2pa/proguard-rules.pro b/android/project/simple_c2pa/proguard-rules.pro @@ -1,25 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile - --dontwarn java.awt.* --keep class com.sun.jna.* { *; } --keepclassmembers class * extends com.sun.jna.* { public *; } diff --git a/android/project/simple_c2pa/src/main/AndroidManifest.xml b/android/project/simple_c2pa/src/main/AndroidManifest.xml @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android"> - -</manifest> diff --git a/apple/.gitlab-ci.yml b/apple/.gitlab-ci.yml @@ -1,58 +0,0 @@ -stages: - - build - - upload - - release - -build_apple: - only: - - main - - develop - - tags - tags: - - proofmode-macos - stage: build - script: - - cargo make apple-build - artifacts: - paths: - - ./out/apple/ - -upload_apple: - only: - - tags - stage: upload - image: curlimages/curl:latest - script: - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./out/apple/SimpleC2PA.swift "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/simple_c2pa/${CI_COMMIT_TAG}/SimpleC2PA.swift"' - - 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file ./out/apple/SimpleC2PA.xcframework.zip "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/simple_c2pa/${CI_COMMIT_TAG}/SimpleC2PA.xcframework.zip"' - -publish_apple: - only: - - tags - stage: release - image: swift:jammy - before_script: - - apt-get update && apt-get install -y git - - git config --global user.email "${GITLAB_USER_EMAIL}" - - git config --global user.name "${GITLAB_USER_NAME}" - - git remote set-url --push origin "https://${GITLAB_ACCESS_USERNAME}:${GITLAB_ACCESS_TOKEN}@gitlab.com/guardianproject/proofmode/simple-c2pa.git" - script: - - git pull origin main - - git checkout main - - cp out/apple/SimpleC2PA.swift apple/src/SimpleC2PA/ - - FRAMEWORK_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/simple_c2pa/${CI_COMMIT_TAG}/SimpleC2PA.xcframework.zip" - - echo "Calculating checksum..." - - CHECKSUM=$(swift package compute-checksum ./out/apple/SimpleC2PA.xcframework.zip) - - echo "Updating Package.swift..." - - echo $FRAMEWORK_URL - - echo $CHECKSUM - - 'sed -i "s|url: \".*\"|url: \"${FRAMEWORK_URL}\"|g" Package.swift' - - 'sed -i "s|checksum: \".*\"|checksum: \"${CHECKSUM}\"|g" Package.swift' - - git add Package.swift - - git add apple/src/SimpleC2PA/SimpleC2PA.swift - - git commit -m "Update Swift files" - - git push origin main - - git push --delete origin $CI_COMMIT_TAG - - git tag -d $CI_COMMIT_TAG - - git tag $CI_COMMIT_TAG - - git push origin $CI_COMMIT_TAG diff --git a/apple/src/SimpleC2PA/SimpleC2PA.swift b/apple/src/SimpleC2PA/SimpleC2PA.swift @@ -1,1836 +0,0 @@ -// This file was autogenerated by some hot garbage in the `uniffi` crate. -// Trust me, you don't want to mess with it! -import Foundation - -// Depending on the consumer's build setup, the low-level FFI code -// might be in a separate module, or it might be compiled inline into -// this module. This is a bit of light hackery to work with both. -#if canImport(SimpleC2PAFFI) -import SimpleC2PAFFI -#endif - -fileprivate extension RustBuffer { - // Allocate a new buffer, copying the contents of a `UInt8` array. - init(bytes: [UInt8]) { - let rbuf = bytes.withUnsafeBufferPointer { ptr in - RustBuffer.from(ptr) - } - self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) - } - - static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer { - try! rustCall { ffi_simple_c2pa_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } - } - - // Frees the buffer in place. - // The buffer must not be used after this is called. - func deallocate() { - try! rustCall { ffi_simple_c2pa_rustbuffer_free(self, $0) } - } -} - -fileprivate extension ForeignBytes { - init(bufferPointer: UnsafeBufferPointer<UInt8>) { - self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) - } -} - -// For every type used in the interface, we provide helper methods for conveniently -// lifting and lowering that type from C-compatible data, and for reading and writing -// values of that type in a buffer. - -// Helper classes/extensions that don't change. -// Someday, this will be in a library of its own. - -fileprivate extension Data { - init(rustBuffer: RustBuffer) { - // TODO: This copies the buffer. Can we read directly from a - // Rust buffer? - self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) - } -} - -// Define reader functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. -// -// With external types, one swift source file needs to be able to call the read -// method on another source file's FfiConverter, but then what visibility -// should Reader have? -// - If Reader is fileprivate, then this means the read() must also -// be fileprivate, which doesn't work with external types. -// - If Reader is internal/public, we'll get compile errors since both source -// files will try define the same type. -// -// Instead, the read() method and these helper functions input a tuple of data - -fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { - (data: data, offset: 0) -} - -// Reads an integer at the current offset, in big-endian order, and advances -// the offset on success. Throws if reading the integer would move the -// offset past the end of the buffer. -fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { - let range = reader.offset..<reader.offset + MemoryLayout<T>.size - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - if T.self == UInt8.self { - let value = reader.data[reader.offset] - reader.offset += 1 - return value as! T - } - var value: T = 0 - let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) - reader.offset = range.upperBound - return value.bigEndian -} - -// Reads an arbitrary number of bytes, to be used to read -// raw bytes, this is useful when lifting strings -fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> { - let range = reader.offset..<(reader.offset+count) - guard reader.data.count >= range.upperBound else { - throw UniffiInternalError.bufferOverflow - } - var value = [UInt8](repeating: 0, count: count) - value.withUnsafeMutableBufferPointer({ buffer in - reader.data.copyBytes(to: buffer, from: range) - }) - reader.offset = range.upperBound - return value -} - -// Reads a float at the current offset. -fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { - return Float(bitPattern: try readInt(&reader)) -} - -// Reads a float at the current offset. -fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { - return Double(bitPattern: try readInt(&reader)) -} - -// Indicates if the offset has reached the end of the buffer. -fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { - return reader.offset < reader.data.count -} - -// Define writer functionality. Normally this would be defined in a class or -// struct, but we use standalone functions instead in order to make external -// types work. See the above discussion on Readers for details. - -fileprivate func createWriter() -> [UInt8] { - return [] -} - -fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { - writer.append(contentsOf: byteArr) -} - -// Writes an integer in big-endian order. -// -// Warning: make sure what you are trying to write -// is in the correct type! -fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) { - var value = value.bigEndian - withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } -} - -fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { - writeInt(&writer, value.bitPattern) -} - -fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { - writeInt(&writer, value.bitPattern) -} - -// Protocol for types that transfer other types across the FFI. This is -// analogous go the Rust trait of the same name. -fileprivate protocol FfiConverter { - associatedtype FfiType - associatedtype SwiftType - - static func lift(_ value: FfiType) throws -> SwiftType - static func lower(_ value: SwiftType) -> FfiType - static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType - static func write(_ value: SwiftType, into buf: inout [UInt8]) -} - -// Types conforming to `Primitive` pass themselves directly over the FFI. -fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } - -extension FfiConverterPrimitive { - public static func lift(_ value: FfiType) throws -> SwiftType { - return value - } - - public static func lower(_ value: SwiftType) -> FfiType { - return value - } -} - -// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. -// Used for complex types where it's hard to write a custom lift/lower. -fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} - -extension FfiConverterRustBuffer { - public static func lift(_ buf: RustBuffer) throws -> SwiftType { - var reader = createReader(data: Data(rustBuffer: buf)) - let value = try read(from: &reader) - if hasRemaining(reader) { - throw UniffiInternalError.incompleteData - } - buf.deallocate() - return value - } - - public static func lower(_ value: SwiftType) -> RustBuffer { - var writer = createWriter() - write(value, into: &writer) - return RustBuffer(bytes: writer) - } -} -// An error type for FFI errors. These errors occur at the UniFFI level, not -// the library level. -fileprivate enum UniffiInternalError: LocalizedError { - case bufferOverflow - case incompleteData - case unexpectedOptionalTag - case unexpectedEnumCase - case unexpectedNullPointer - case unexpectedRustCallStatusCode - case unexpectedRustCallError - case unexpectedStaleHandle - case rustPanic(_ message: String) - - public var errorDescription: String? { - switch self { - case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" - case .incompleteData: return "The buffer still has data after lifting its containing value" - case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" - case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" - case .unexpectedNullPointer: return "Raw pointer value was null" - case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" - case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" - case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" - case let .rustPanic(message): return message - } - } -} - -fileprivate let CALL_SUCCESS: Int8 = 0 -fileprivate let CALL_ERROR: Int8 = 1 -fileprivate let CALL_PANIC: Int8 = 2 -fileprivate let CALL_CANCELLED: Int8 = 3 - -fileprivate extension RustCallStatus { - init() { - self.init( - code: CALL_SUCCESS, - errorBuf: RustBuffer.init( - capacity: 0, - len: 0, - data: nil - ) - ) - } -} - -private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T { - try makeRustCall(callback, errorHandler: nil) -} - -private func rustCallWithError<T>( - _ errorHandler: @escaping (RustBuffer) throws -> Error, - _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T { - try makeRustCall(callback, errorHandler: errorHandler) -} - -private func makeRustCall<T>( - _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T, - errorHandler: ((RustBuffer) throws -> Error)? -) throws -> T { - uniffiEnsureInitialized() - var callStatus = RustCallStatus.init() - let returnedVal = callback(&callStatus) - try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) - return returnedVal -} - -private func uniffiCheckCallStatus( - callStatus: RustCallStatus, - errorHandler: ((RustBuffer) throws -> Error)? -) throws { - switch callStatus.code { - case CALL_SUCCESS: - return - - case CALL_ERROR: - if let errorHandler = errorHandler { - throw try errorHandler(callStatus.errorBuf) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.unexpectedRustCallError - } - - case CALL_PANIC: - // When the rust code sees a panic, it tries to construct a RustBuffer - // with the message. But if that code panics, then it just sends back - // an empty buffer. - if callStatus.errorBuf.len > 0 { - throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) - } else { - callStatus.errorBuf.deallocate() - throw UniffiInternalError.rustPanic("Rust panic") - } - - case CALL_CANCELLED: - throw CancellationError() - - default: - throw UniffiInternalError.unexpectedRustCallStatusCode - } -} - -// Public interface members begin here. - - -fileprivate struct FfiConverterUInt8: FfiConverterPrimitive { - typealias FfiType = UInt8 - typealias SwiftType = UInt8 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt8 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: UInt8, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { - typealias FfiType = UInt32 - typealias SwiftType = UInt32 - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { - return try lift(readInt(&buf)) - } - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -fileprivate struct FfiConverterDouble: FfiConverterPrimitive { - typealias FfiType = Double - typealias SwiftType = Double - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Double { - return try lift(readDouble(&buf)) - } - - public static func write(_ value: Double, into buf: inout [UInt8]) { - writeDouble(&buf, lower(value)) - } -} - -fileprivate struct FfiConverterBool : FfiConverter { - typealias FfiType = Int8 - typealias SwiftType = Bool - - public static func lift(_ value: Int8) throws -> Bool { - return value != 0 - } - - public static func lower(_ value: Bool) -> Int8 { - return value ? 1 : 0 - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { - return try lift(readInt(&buf)) - } - - public static func write(_ value: Bool, into buf: inout [UInt8]) { - writeInt(&buf, lower(value)) - } -} - -fileprivate struct FfiConverterString: FfiConverter { - typealias SwiftType = String - typealias FfiType = RustBuffer - - public static func lift(_ value: RustBuffer) throws -> String { - defer { - value.deallocate() - } - if value.data == nil { - return String() - } - let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len)) - return String(bytes: bytes, encoding: String.Encoding.utf8)! - } - - public static func lower(_ value: String) -> RustBuffer { - return value.utf8CString.withUnsafeBufferPointer { ptr in - // The swift string gives us int8_t, we want uint8_t. - ptr.withMemoryRebound(to: UInt8.self) { ptr in - // The swift string gives us a trailing null byte, we don't want it. - let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) - return RustBuffer.from(buf) - } - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { - let len: Int32 = try readInt(&buf) - return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! - } - - public static func write(_ value: String, into buf: inout [UInt8]) { - let len = Int32(value.utf8.count) - writeInt(&buf, len) - writeBytes(&buf, value.utf8) - } -} - -fileprivate struct FfiConverterData: FfiConverterRustBuffer { - typealias SwiftType = Data - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data { - let len: Int32 = try readInt(&buf) - return Data(try readBytes(&buf, count: Int(len))) - } - - public static func write(_ value: Data, into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - writeBytes(&buf, value) - } -} - - -public protocol ApplicationInfoProtocol { - -} - -public class ApplicationInfo: ApplicationInfoProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - public convenience init(name: String, version: String, iconUri: String?) { - self.init(unsafeFromRawPointer: try! rustCall() { - uniffi_simple_c2pa_fn_constructor_applicationinfo_new( - FfiConverterString.lower(name), - FfiConverterString.lower(version), - FfiConverterOptionString.lower(iconUri),$0) -}) - } - - deinit { - try! rustCall { uniffi_simple_c2pa_fn_free_applicationinfo(pointer, $0) } - } - - - - - -} - -public struct FfiConverterTypeApplicationInfo: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ApplicationInfo - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ApplicationInfo { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: ApplicationInfo, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ApplicationInfo { - return ApplicationInfo(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: ApplicationInfo) -> UnsafeMutableRawPointer { - return value.pointer - } -} - - -public func FfiConverterTypeApplicationInfo_lift(_ pointer: UnsafeMutableRawPointer) throws -> ApplicationInfo { - return try FfiConverterTypeApplicationInfo.lift(pointer) -} - -public func FfiConverterTypeApplicationInfo_lower(_ value: ApplicationInfo) -> UnsafeMutableRawPointer { - return FfiConverterTypeApplicationInfo.lower(value) -} - - -public protocol CertificateProtocol { - func getCertificateBytes() throws -> Data - func getPrivateKeyBytes() throws -> Data - -} - -public class Certificate: CertificateProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - public convenience init(certificateData: FileData, privateKeyData: FileData, parentCertificate: Certificate?) { - self.init(unsafeFromRawPointer: try! rustCall() { - uniffi_simple_c2pa_fn_constructor_certificate_new( - FfiConverterTypeFileData.lower(certificateData), - FfiConverterTypeFileData.lower(privateKeyData), - FfiConverterOptionTypeCertificate.lower(parentCertificate),$0) -}) - } - - deinit { - try! rustCall { uniffi_simple_c2pa_fn_free_certificate(pointer, $0) } - } - - - - - - - public func getCertificateBytes() throws -> Data { - return try FfiConverterData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_certificate_get_certificate_bytes(self.pointer, $0 - ) -} - ) - } - - public func getPrivateKeyBytes() throws -> Data { - return try FfiConverterData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_certificate_get_private_key_bytes(self.pointer, $0 - ) -} - ) - } -} - -public struct FfiConverterTypeCertificate: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = Certificate - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Certificate { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: Certificate, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> Certificate { - return Certificate(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: Certificate) -> UnsafeMutableRawPointer { - return value.pointer - } -} - - -public func FfiConverterTypeCertificate_lift(_ pointer: UnsafeMutableRawPointer) throws -> Certificate { - return try FfiConverterTypeCertificate.lift(pointer) -} - -public func FfiConverterTypeCertificate_lower(_ value: Certificate) -> UnsafeMutableRawPointer { - return FfiConverterTypeCertificate.lower(value) -} - - -public protocol CertificateOptionsProtocol { - -} - -public class CertificateOptions: CertificateOptionsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - public convenience init(key: FileData, certificateType: CertificateType, parentCertificate: Certificate?, emailAddress: String?, pgpFingerprint: String?) { - self.init(unsafeFromRawPointer: try! rustCall() { - uniffi_simple_c2pa_fn_constructor_certificateoptions_new( - FfiConverterTypeFileData.lower(key), - FfiConverterTypeCertificateType.lower(certificateType), - FfiConverterOptionTypeCertificate.lower(parentCertificate), - FfiConverterOptionString.lower(emailAddress), - FfiConverterOptionString.lower(pgpFingerprint),$0) -}) - } - - deinit { - try! rustCall { uniffi_simple_c2pa_fn_free_certificateoptions(pointer, $0) } - } - - - - - -} - -public struct FfiConverterTypeCertificateOptions: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = CertificateOptions - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CertificateOptions { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: CertificateOptions, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> CertificateOptions { - return CertificateOptions(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: CertificateOptions) -> UnsafeMutableRawPointer { - return value.pointer - } -} - - -public func FfiConverterTypeCertificateOptions_lift(_ pointer: UnsafeMutableRawPointer) throws -> CertificateOptions { - return try FfiConverterTypeCertificateOptions.lift(pointer) -} - -public func FfiConverterTypeCertificateOptions_lower(_ value: CertificateOptions) -> UnsafeMutableRawPointer { - return FfiConverterTypeCertificateOptions.lower(value) -} - - -public protocol ContentCredentialsProtocol { - func addCreatedAssertion() throws - func addCustomAiTrainingAssertions(options: CustomAiTrainingOptions) throws - func addEmailAssertion(email: String, displayName: String) throws - func addExifAssertion(exifData: ExifData) throws - func addInstagramAssertion(username: String, displayName: String) throws - func addJsonAssertion(label: String, json: String) throws - func addPermissiveAiTrainingAssertions() throws - func addPgpAssertion(fingerprint: String, displayName: String) throws - func addPlacedAssertion() throws - func addRestrictedAiTrainingAssertions() throws - func addWebsiteAssertion(url: String) throws - func embedManifest(outputPath: String?) throws -> FileData - func exportManifest(outputPath: String?) throws -> FileData - func signManifest(embed: Bool, outputPath: String?) throws -> FileData - func signManifestWithCertificate(certificate: Certificate, outputFile: FileData) throws - -} - -public class ContentCredentials: ContentCredentialsProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - public convenience init(certificate: Certificate, file: FileData, applicationInfo: ApplicationInfo?) { - self.init(unsafeFromRawPointer: try! rustCall() { - uniffi_simple_c2pa_fn_constructor_contentcredentials_new( - FfiConverterTypeCertificate.lower(certificate), - FfiConverterTypeFileData.lower(file), - FfiConverterOptionTypeApplicationInfo.lower(applicationInfo),$0) -}) - } - - deinit { - try! rustCall { uniffi_simple_c2pa_fn_free_contentcredentials(pointer, $0) } - } - - - - - - - public func addCreatedAssertion() throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_created_assertion(self.pointer, $0 - ) -} - } - - public func addCustomAiTrainingAssertions(options: CustomAiTrainingOptions) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_custom_ai_training_assertions(self.pointer, - FfiConverterTypeCustomAITrainingOptions.lower(options),$0 - ) -} - } - - public func addEmailAssertion(email: String, displayName: String) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_email_assertion(self.pointer, - FfiConverterString.lower(email), - FfiConverterString.lower(displayName),$0 - ) -} - } - - public func addExifAssertion(exifData: ExifData) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_exif_assertion(self.pointer, - FfiConverterTypeExifData.lower(exifData),$0 - ) -} - } - - public func addInstagramAssertion(username: String, displayName: String) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_instagram_assertion(self.pointer, - FfiConverterString.lower(username), - FfiConverterString.lower(displayName),$0 - ) -} - } - - public func addJsonAssertion(label: String, json: String) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_json_assertion(self.pointer, - FfiConverterString.lower(label), - FfiConverterString.lower(json),$0 - ) -} - } - - public func addPermissiveAiTrainingAssertions() throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_permissive_ai_training_assertions(self.pointer, $0 - ) -} - } - - public func addPgpAssertion(fingerprint: String, displayName: String) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_pgp_assertion(self.pointer, - FfiConverterString.lower(fingerprint), - FfiConverterString.lower(displayName),$0 - ) -} - } - - public func addPlacedAssertion() throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_placed_assertion(self.pointer, $0 - ) -} - } - - public func addRestrictedAiTrainingAssertions() throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_restricted_ai_training_assertions(self.pointer, $0 - ) -} - } - - public func addWebsiteAssertion(url: String) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_add_website_assertion(self.pointer, - FfiConverterString.lower(url),$0 - ) -} - } - - public func embedManifest(outputPath: String?) throws -> FileData { - return try FfiConverterTypeFileData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_embed_manifest(self.pointer, - FfiConverterOptionString.lower(outputPath),$0 - ) -} - ) - } - - public func exportManifest(outputPath: String?) throws -> FileData { - return try FfiConverterTypeFileData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_export_manifest(self.pointer, - FfiConverterOptionString.lower(outputPath),$0 - ) -} - ) - } - - public func signManifest(embed: Bool, outputPath: String?) throws -> FileData { - return try FfiConverterTypeFileData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_sign_manifest(self.pointer, - FfiConverterBool.lower(embed), - FfiConverterOptionString.lower(outputPath),$0 - ) -} - ) - } - - public func signManifestWithCertificate(certificate: Certificate, outputFile: FileData) throws { - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_contentcredentials_sign_manifest_with_certificate(self.pointer, - FfiConverterTypeCertificate.lower(certificate), - FfiConverterTypeFileData.lower(outputFile),$0 - ) -} - } -} - -public struct FfiConverterTypeContentCredentials: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = ContentCredentials - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ContentCredentials { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: ContentCredentials, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ContentCredentials { - return ContentCredentials(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: ContentCredentials) -> UnsafeMutableRawPointer { - return value.pointer - } -} - - -public func FfiConverterTypeContentCredentials_lift(_ pointer: UnsafeMutableRawPointer) throws -> ContentCredentials { - return try FfiConverterTypeContentCredentials.lift(pointer) -} - -public func FfiConverterTypeContentCredentials_lower(_ value: ContentCredentials) -> UnsafeMutableRawPointer { - return FfiConverterTypeContentCredentials.lower(value) -} - - -public protocol FileDataProtocol { - func getBytes() throws -> Data - func getPath() throws -> String - -} - -public class FileData: FileDataProtocol { - fileprivate let pointer: UnsafeMutableRawPointer - - // TODO: We'd like this to be `private` but for Swifty reasons, - // we can't implement `FfiConverter` without making this `required` and we can't - // make it `required` without making it `public`. - required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { - self.pointer = pointer - } - public convenience init(path: String?, bytes: Data?, fileName: String?) { - self.init(unsafeFromRawPointer: try! rustCall() { - uniffi_simple_c2pa_fn_constructor_filedata_new( - FfiConverterOptionString.lower(path), - FfiConverterOptionData.lower(bytes), - FfiConverterOptionString.lower(fileName),$0) -}) - } - - deinit { - try! rustCall { uniffi_simple_c2pa_fn_free_filedata(pointer, $0) } - } - - - - - - - public func getBytes() throws -> Data { - return try FfiConverterData.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_filedata_get_bytes(self.pointer, $0 - ) -} - ) - } - - public func getPath() throws -> String { - return try FfiConverterString.lift( - try - rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_method_filedata_get_path(self.pointer, $0 - ) -} - ) - } -} - -public struct FfiConverterTypeFileData: FfiConverter { - typealias FfiType = UnsafeMutableRawPointer - typealias SwiftType = FileData - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FileData { - let v: UInt64 = try readInt(&buf) - // The Rust code won't compile if a pointer won't fit in a UInt64. - // We have to go via `UInt` because that's the thing that's the size of a pointer. - let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) - if (ptr == nil) { - throw UniffiInternalError.unexpectedNullPointer - } - return try lift(ptr!) - } - - public static func write(_ value: FileData, into buf: inout [UInt8]) { - // This fiddling is because `Int` is the thing that's the same size as a pointer. - // The Rust code won't compile if a pointer won't fit in a `UInt64`. - writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) - } - - public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> FileData { - return FileData(unsafeFromRawPointer: pointer) - } - - public static func lower(_ value: FileData) -> UnsafeMutableRawPointer { - return value.pointer - } -} - - -public func FfiConverterTypeFileData_lift(_ pointer: UnsafeMutableRawPointer) throws -> FileData { - return try FfiConverterTypeFileData.lift(pointer) -} - -public func FfiConverterTypeFileData_lower(_ value: FileData) -> UnsafeMutableRawPointer { - return FfiConverterTypeFileData.lower(value) -} - - -public struct CustomAiTrainingOptions { - public var aiTraining: AiDataMiningUsage - public var aiGenerativeTraining: AiDataMiningUsage - public var dataMining: AiDataMiningUsage - public var inference: AiDataMiningUsage - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(aiTraining: AiDataMiningUsage, aiGenerativeTraining: AiDataMiningUsage, dataMining: AiDataMiningUsage, inference: AiDataMiningUsage) { - self.aiTraining = aiTraining - self.aiGenerativeTraining = aiGenerativeTraining - self.dataMining = dataMining - self.inference = inference - } -} - - -extension CustomAiTrainingOptions: Equatable, Hashable { - public static func ==(lhs: CustomAiTrainingOptions, rhs: CustomAiTrainingOptions) -> Bool { - if lhs.aiTraining != rhs.aiTraining { - return false - } - if lhs.aiGenerativeTraining != rhs.aiGenerativeTraining { - return false - } - if lhs.dataMining != rhs.dataMining { - return false - } - if lhs.inference != rhs.inference { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(aiTraining) - hasher.combine(aiGenerativeTraining) - hasher.combine(dataMining) - hasher.combine(inference) - } -} - - -public struct FfiConverterTypeCustomAITrainingOptions: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CustomAiTrainingOptions { - return try CustomAiTrainingOptions( - aiTraining: FfiConverterTypeAIDataMiningUsage.read(from: &buf), - aiGenerativeTraining: FfiConverterTypeAIDataMiningUsage.read(from: &buf), - dataMining: FfiConverterTypeAIDataMiningUsage.read(from: &buf), - inference: FfiConverterTypeAIDataMiningUsage.read(from: &buf) - ) - } - - public static func write(_ value: CustomAiTrainingOptions, into buf: inout [UInt8]) { - FfiConverterTypeAIDataMiningUsage.write(value.aiTraining, into: &buf) - FfiConverterTypeAIDataMiningUsage.write(value.aiGenerativeTraining, into: &buf) - FfiConverterTypeAIDataMiningUsage.write(value.dataMining, into: &buf) - FfiConverterTypeAIDataMiningUsage.write(value.inference, into: &buf) - } -} - - -public func FfiConverterTypeCustomAITrainingOptions_lift(_ buf: RustBuffer) throws -> CustomAiTrainingOptions { - return try FfiConverterTypeCustomAITrainingOptions.lift(buf) -} - -public func FfiConverterTypeCustomAITrainingOptions_lower(_ value: CustomAiTrainingOptions) -> RustBuffer { - return FfiConverterTypeCustomAITrainingOptions.lower(value) -} - - -public struct ExifData { - public var gpsVersionId: String? - public var latitude: String? - public var longitude: String? - public var altitudeRef: UInt8? - public var altitude: String? - public var timestamp: String? - public var speedRef: String? - public var speed: String? - public var directionRef: String? - public var direction: String? - public var destinationBearingRef: String? - public var destinationBearing: String? - public var positioningError: String? - public var exposureTime: String? - public var fNumber: Double? - public var colorSpace: UInt8? - public var digitalZoomRatio: Double? - public var make: String? - public var model: String? - public var lensMake: String? - public var lensModel: String? - public var lensSpecification: [Double]? - - // Default memberwise initializers are never public by default, so we - // declare one manually. - public init(gpsVersionId: String?, latitude: String?, longitude: String?, altitudeRef: UInt8?, altitude: String?, timestamp: String?, speedRef: String?, speed: String?, directionRef: String?, direction: String?, destinationBearingRef: String?, destinationBearing: String?, positioningError: String?, exposureTime: String?, fNumber: Double?, colorSpace: UInt8?, digitalZoomRatio: Double?, make: String?, model: String?, lensMake: String?, lensModel: String?, lensSpecification: [Double]?) { - self.gpsVersionId = gpsVersionId - self.latitude = latitude - self.longitude = longitude - self.altitudeRef = altitudeRef - self.altitude = altitude - self.timestamp = timestamp - self.speedRef = speedRef - self.speed = speed - self.directionRef = directionRef - self.direction = direction - self.destinationBearingRef = destinationBearingRef - self.destinationBearing = destinationBearing - self.positioningError = positioningError - self.exposureTime = exposureTime - self.fNumber = fNumber - self.colorSpace = colorSpace - self.digitalZoomRatio = digitalZoomRatio - self.make = make - self.model = model - self.lensMake = lensMake - self.lensModel = lensModel - self.lensSpecification = lensSpecification - } -} - - -extension ExifData: Equatable, Hashable { - public static func ==(lhs: ExifData, rhs: ExifData) -> Bool { - if lhs.gpsVersionId != rhs.gpsVersionId { - return false - } - if lhs.latitude != rhs.latitude { - return false - } - if lhs.longitude != rhs.longitude { - return false - } - if lhs.altitudeRef != rhs.altitudeRef { - return false - } - if lhs.altitude != rhs.altitude { - return false - } - if lhs.timestamp != rhs.timestamp { - return false - } - if lhs.speedRef != rhs.speedRef { - return false - } - if lhs.speed != rhs.speed { - return false - } - if lhs.directionRef != rhs.directionRef { - return false - } - if lhs.direction != rhs.direction { - return false - } - if lhs.destinationBearingRef != rhs.destinationBearingRef { - return false - } - if lhs.destinationBearing != rhs.destinationBearing { - return false - } - if lhs.positioningError != rhs.positioningError { - return false - } - if lhs.exposureTime != rhs.exposureTime { - return false - } - if lhs.fNumber != rhs.fNumber { - return false - } - if lhs.colorSpace != rhs.colorSpace { - return false - } - if lhs.digitalZoomRatio != rhs.digitalZoomRatio { - return false - } - if lhs.make != rhs.make { - return false - } - if lhs.model != rhs.model { - return false - } - if lhs.lensMake != rhs.lensMake { - return false - } - if lhs.lensModel != rhs.lensModel { - return false - } - if lhs.lensSpecification != rhs.lensSpecification { - return false - } - return true - } - - public func hash(into hasher: inout Hasher) { - hasher.combine(gpsVersionId) - hasher.combine(latitude) - hasher.combine(longitude) - hasher.combine(altitudeRef) - hasher.combine(altitude) - hasher.combine(timestamp) - hasher.combine(speedRef) - hasher.combine(speed) - hasher.combine(directionRef) - hasher.combine(direction) - hasher.combine(destinationBearingRef) - hasher.combine(destinationBearing) - hasher.combine(positioningError) - hasher.combine(exposureTime) - hasher.combine(fNumber) - hasher.combine(colorSpace) - hasher.combine(digitalZoomRatio) - hasher.combine(make) - hasher.combine(model) - hasher.combine(lensMake) - hasher.combine(lensModel) - hasher.combine(lensSpecification) - } -} - - -public struct FfiConverterTypeExifData: FfiConverterRustBuffer { - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ExifData { - return try ExifData( - gpsVersionId: FfiConverterOptionString.read(from: &buf), - latitude: FfiConverterOptionString.read(from: &buf), - longitude: FfiConverterOptionString.read(from: &buf), - altitudeRef: FfiConverterOptionUInt8.read(from: &buf), - altitude: FfiConverterOptionString.read(from: &buf), - timestamp: FfiConverterOptionString.read(from: &buf), - speedRef: FfiConverterOptionString.read(from: &buf), - speed: FfiConverterOptionString.read(from: &buf), - directionRef: FfiConverterOptionString.read(from: &buf), - direction: FfiConverterOptionString.read(from: &buf), - destinationBearingRef: FfiConverterOptionString.read(from: &buf), - destinationBearing: FfiConverterOptionString.read(from: &buf), - positioningError: FfiConverterOptionString.read(from: &buf), - exposureTime: FfiConverterOptionString.read(from: &buf), - fNumber: FfiConverterOptionDouble.read(from: &buf), - colorSpace: FfiConverterOptionUInt8.read(from: &buf), - digitalZoomRatio: FfiConverterOptionDouble.read(from: &buf), - make: FfiConverterOptionString.read(from: &buf), - model: FfiConverterOptionString.read(from: &buf), - lensMake: FfiConverterOptionString.read(from: &buf), - lensModel: FfiConverterOptionString.read(from: &buf), - lensSpecification: FfiConverterOptionSequenceDouble.read(from: &buf) - ) - } - - public static func write(_ value: ExifData, into buf: inout [UInt8]) { - FfiConverterOptionString.write(value.gpsVersionId, into: &buf) - FfiConverterOptionString.write(value.latitude, into: &buf) - FfiConverterOptionString.write(value.longitude, into: &buf) - FfiConverterOptionUInt8.write(value.altitudeRef, into: &buf) - FfiConverterOptionString.write(value.altitude, into: &buf) - FfiConverterOptionString.write(value.timestamp, into: &buf) - FfiConverterOptionString.write(value.speedRef, into: &buf) - FfiConverterOptionString.write(value.speed, into: &buf) - FfiConverterOptionString.write(value.directionRef, into: &buf) - FfiConverterOptionString.write(value.direction, into: &buf) - FfiConverterOptionString.write(value.destinationBearingRef, into: &buf) - FfiConverterOptionString.write(value.destinationBearing, into: &buf) - FfiConverterOptionString.write(value.positioningError, into: &buf) - FfiConverterOptionString.write(value.exposureTime, into: &buf) - FfiConverterOptionDouble.write(value.fNumber, into: &buf) - FfiConverterOptionUInt8.write(value.colorSpace, into: &buf) - FfiConverterOptionDouble.write(value.digitalZoomRatio, into: &buf) - FfiConverterOptionString.write(value.make, into: &buf) - FfiConverterOptionString.write(value.model, into: &buf) - FfiConverterOptionString.write(value.lensMake, into: &buf) - FfiConverterOptionString.write(value.lensModel, into: &buf) - FfiConverterOptionSequenceDouble.write(value.lensSpecification, into: &buf) - } -} - - -public func FfiConverterTypeExifData_lift(_ buf: RustBuffer) throws -> ExifData { - return try FfiConverterTypeExifData.lift(buf) -} - -public func FfiConverterTypeExifData_lower(_ value: ExifData) -> RustBuffer { - return FfiConverterTypeExifData.lower(value) -} - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum AiDataMiningUsage { - - case allowed - case notAllowed - case constrained(constraintInfo: String) -} - -public struct FfiConverterTypeAIDataMiningUsage: FfiConverterRustBuffer { - typealias SwiftType = AiDataMiningUsage - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AiDataMiningUsage { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .allowed - - case 2: return .notAllowed - - case 3: return .constrained( - constraintInfo: try FfiConverterString.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: AiDataMiningUsage, into buf: inout [UInt8]) { - switch value { - - - case .allowed: - writeInt(&buf, Int32(1)) - - - case .notAllowed: - writeInt(&buf, Int32(2)) - - - case let .constrained(constraintInfo): - writeInt(&buf, Int32(3)) - FfiConverterString.write(constraintInfo, into: &buf) - - } - } -} - - -public func FfiConverterTypeAIDataMiningUsage_lift(_ buf: RustBuffer) throws -> AiDataMiningUsage { - return try FfiConverterTypeAIDataMiningUsage.lift(buf) -} - -public func FfiConverterTypeAIDataMiningUsage_lower(_ value: AiDataMiningUsage) -> RustBuffer { - return FfiConverterTypeAIDataMiningUsage.lower(value) -} - - -extension AiDataMiningUsage: Equatable, Hashable {} - - - -// Note that we don't yet support `indirect` for enums. -// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. -public enum CertificateType { - - case onlineRoot(organization: String?, validityDays: UInt32?) - case onlineIntermediate(organization: String?, validityDays: UInt32?) - case offlineRoot(organization: String?, validityDays: UInt32?) - case offlineIntermediate(organization: String?, validityDays: UInt32?) - case contentCredentials(organization: String?, validityDays: UInt32?) -} - -public struct FfiConverterTypeCertificateType: FfiConverterRustBuffer { - typealias SwiftType = CertificateType - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CertificateType { - let variant: Int32 = try readInt(&buf) - switch variant { - - case 1: return .onlineRoot( - organization: try FfiConverterOptionString.read(from: &buf), - validityDays: try FfiConverterOptionUInt32.read(from: &buf) - ) - - case 2: return .onlineIntermediate( - organization: try FfiConverterOptionString.read(from: &buf), - validityDays: try FfiConverterOptionUInt32.read(from: &buf) - ) - - case 3: return .offlineRoot( - organization: try FfiConverterOptionString.read(from: &buf), - validityDays: try FfiConverterOptionUInt32.read(from: &buf) - ) - - case 4: return .offlineIntermediate( - organization: try FfiConverterOptionString.read(from: &buf), - validityDays: try FfiConverterOptionUInt32.read(from: &buf) - ) - - case 5: return .contentCredentials( - organization: try FfiConverterOptionString.read(from: &buf), - validityDays: try FfiConverterOptionUInt32.read(from: &buf) - ) - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: CertificateType, into buf: inout [UInt8]) { - switch value { - - - case let .onlineRoot(organization,validityDays): - writeInt(&buf, Int32(1)) - FfiConverterOptionString.write(organization, into: &buf) - FfiConverterOptionUInt32.write(validityDays, into: &buf) - - - case let .onlineIntermediate(organization,validityDays): - writeInt(&buf, Int32(2)) - FfiConverterOptionString.write(organization, into: &buf) - FfiConverterOptionUInt32.write(validityDays, into: &buf) - - - case let .offlineRoot(organization,validityDays): - writeInt(&buf, Int32(3)) - FfiConverterOptionString.write(organization, into: &buf) - FfiConverterOptionUInt32.write(validityDays, into: &buf) - - - case let .offlineIntermediate(organization,validityDays): - writeInt(&buf, Int32(4)) - FfiConverterOptionString.write(organization, into: &buf) - FfiConverterOptionUInt32.write(validityDays, into: &buf) - - - case let .contentCredentials(organization,validityDays): - writeInt(&buf, Int32(5)) - FfiConverterOptionString.write(organization, into: &buf) - FfiConverterOptionUInt32.write(validityDays, into: &buf) - - } - } -} - - -public func FfiConverterTypeCertificateType_lift(_ buf: RustBuffer) throws -> CertificateType { - return try FfiConverterTypeCertificateType.lift(buf) -} - -public func FfiConverterTypeCertificateType_lower(_ value: CertificateType) -> RustBuffer { - return FfiConverterTypeCertificateType.lower(value) -} - - -extension CertificateType: Equatable, Hashable {} - - - -public enum SimpleC2paError { - - - - // Simple error enums only carry a message - case Failure(message: String) - - // Simple error enums only carry a message - case Unexpected(message: String) - - - fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { - return try FfiConverterTypeSimpleC2PAError.lift(error) - } -} - - -public struct FfiConverterTypeSimpleC2PAError: FfiConverterRustBuffer { - typealias SwiftType = SimpleC2paError - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SimpleC2paError { - let variant: Int32 = try readInt(&buf) - switch variant { - - - - - case 1: return .Failure( - message: try FfiConverterString.read(from: &buf) - ) - - case 2: return .Unexpected( - message: try FfiConverterString.read(from: &buf) - ) - - - default: throw UniffiInternalError.unexpectedEnumCase - } - } - - public static func write(_ value: SimpleC2paError, into buf: inout [UInt8]) { - switch value { - - - - - case .Failure(_ /* message is ignored*/): - writeInt(&buf, Int32(1)) - case .Unexpected(_ /* message is ignored*/): - writeInt(&buf, Int32(2)) - - - } - } -} - - -extension SimpleC2paError: Equatable, Hashable {} - -extension SimpleC2paError: Error { } - -fileprivate struct FfiConverterOptionUInt8: FfiConverterRustBuffer { - typealias SwiftType = UInt8? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt8.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterUInt8.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { - typealias SwiftType = UInt32? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterUInt32.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterUInt32.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionDouble: FfiConverterRustBuffer { - typealias SwiftType = Double? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterDouble.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterDouble.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { - typealias SwiftType = String? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterString.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterString.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionData: FfiConverterRustBuffer { - typealias SwiftType = Data? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterData.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterData.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionTypeApplicationInfo: FfiConverterRustBuffer { - typealias SwiftType = ApplicationInfo? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeApplicationInfo.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeApplicationInfo.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionTypeCertificate: FfiConverterRustBuffer { - typealias SwiftType = Certificate? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterTypeCertificate.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterTypeCertificate.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterOptionSequenceDouble: FfiConverterRustBuffer { - typealias SwiftType = [Double]? - - public static func write(_ value: SwiftType, into buf: inout [UInt8]) { - guard let value = value else { - writeInt(&buf, Int8(0)) - return - } - writeInt(&buf, Int8(1)) - FfiConverterSequenceDouble.write(value, into: &buf) - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { - switch try readInt(&buf) as Int8 { - case 0: return nil - case 1: return try FfiConverterSequenceDouble.read(from: &buf) - default: throw UniffiInternalError.unexpectedOptionalTag - } - } -} - -fileprivate struct FfiConverterSequenceDouble: FfiConverterRustBuffer { - typealias SwiftType = [Double] - - public static func write(_ value: [Double], into buf: inout [UInt8]) { - let len = Int32(value.count) - writeInt(&buf, len) - for item in value { - FfiConverterDouble.write(item, into: &buf) - } - } - - public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Double] { - let len: Int32 = try readInt(&buf) - var seq = [Double]() - seq.reserveCapacity(Int(len)) - for _ in 0 ..< len { - seq.append(try FfiConverterDouble.read(from: &buf)) - } - return seq - } -} - -public func createCertificate(options: CertificateOptions) throws -> Certificate { - return try FfiConverterTypeCertificate.lift( - try rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_func_create_certificate( - FfiConverterTypeCertificateOptions.lower(options),$0) -} - ) -} - -public func createContentCredentialsCertificate(rootCertificate: Certificate?, organization: String?, validityDays: UInt32?) throws -> Certificate { - return try FfiConverterTypeCertificate.lift( - try rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_func_create_content_credentials_certificate( - FfiConverterOptionTypeCertificate.lower(rootCertificate), - FfiConverterOptionString.lower(organization), - FfiConverterOptionUInt32.lower(validityDays),$0) -} - ) -} - -public func createPrivateKey() throws -> FileData { - return try FfiConverterTypeFileData.lift( - try rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_func_create_private_key($0) -} - ) -} - -public func createRootCertificate(organization: String?, validityDays: UInt32?) throws -> Certificate { - return try FfiConverterTypeCertificate.lift( - try rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_func_create_root_certificate( - FfiConverterOptionString.lower(organization), - FfiConverterOptionUInt32.lower(validityDays),$0) -} - ) -} - -public func requestSignedCertificate(options: CertificateOptions) throws -> String { - return try FfiConverterString.lift( - try rustCallWithError(FfiConverterTypeSimpleC2PAError.lift) { - uniffi_simple_c2pa_fn_func_request_signed_certificate( - FfiConverterTypeCertificateOptions.lower(options),$0) -} - ) -} - -private enum InitializationResult { - case ok - case contractVersionMismatch - case apiChecksumMismatch -} -// Use a global variables to perform the versioning checks. Swift ensures that -// the code inside is only computed once. -private var initializationResult: InitializationResult { - // Get the bindings contract version from our ComponentInterface - let bindings_contract_version = 24 - // Get the scaffolding contract version by calling the into the dylib - let scaffolding_contract_version = ffi_simple_c2pa_uniffi_contract_version() - if bindings_contract_version != scaffolding_contract_version { - return InitializationResult.contractVersionMismatch - } - if (uniffi_simple_c2pa_checksum_func_create_certificate() != 34310) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_func_create_content_credentials_certificate() != 25230) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_func_create_private_key() != 61208) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_func_create_root_certificate() != 4408) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_func_request_signed_certificate() != 18474) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_certificate_get_certificate_bytes() != 18161) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_certificate_get_private_key_bytes() != 42096) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_created_assertion() != 61395) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_custom_ai_training_assertions() != 32506) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_email_assertion() != 43840) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_exif_assertion() != 12750) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_instagram_assertion() != 60237) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_json_assertion() != 29285) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_permissive_ai_training_assertions() != 45270) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_pgp_assertion() != 55991) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_placed_assertion() != 41702) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_restricted_ai_training_assertions() != 63406) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_add_website_assertion() != 6602) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_embed_manifest() != 19522) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_export_manifest() != 10130) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_sign_manifest() != 40977) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_contentcredentials_sign_manifest_with_certificate() != 2932) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_filedata_get_bytes() != 59331) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_method_filedata_get_path() != 6887) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_constructor_applicationinfo_new() != 22446) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_constructor_certificate_new() != 33607) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_constructor_certificateoptions_new() != 27700) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_constructor_contentcredentials_new() != 49391) { - return InitializationResult.apiChecksumMismatch - } - if (uniffi_simple_c2pa_checksum_constructor_filedata_new() != 65000) { - return InitializationResult.apiChecksumMismatch - } - - return InitializationResult.ok -} - -private func uniffiEnsureInitialized() { - switch initializationResult { - case .ok: - break - case .contractVersionMismatch: - fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") - case .apiChecksumMismatch: - fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") - } -} -\ No newline at end of file diff --git a/src/assertions.rs b/src/assertions.rs @@ -1,96 +1,90 @@ -use crate::common::SimpleC2PAError; -use crate::content_credentials::ContentCredentials; +use std::borrow::Cow; +use std::result::Result; + use c2pa::assertions::{c2pa_action, labels, Action, Actions, Exif, SchemaDotOrg}; use serde::{Deserialize, Serialize}; -use std::result::Result; -#[derive(uniffi::Record)] -pub struct ExifData { - pub gps_version_id: Option<String>, - pub latitude: Option<String>, - pub longitude: Option<String>, +use crate::common::SimpleC2PAError; +use crate::content_credentials::ContentCredentials; + +pub struct ExifData<'a> { + pub gps_version_id: Option<Cow<'a, str>>, + pub latitude: Option<Cow<'a, str>>, + pub longitude: Option<Cow<'a, str>>, pub altitude_ref: Option<u8>, - pub altitude: Option<String>, - pub timestamp: Option<String>, - pub speed_ref: Option<String>, - pub speed: Option<String>, - pub direction_ref: Option<String>, - pub direction: Option<String>, - pub destination_bearing_ref: Option<String>, - pub destination_bearing: Option<String>, - pub positioning_error: Option<String>, - pub exposure_time: Option<String>, + pub altitude: Option<Cow<'a, str>>, + pub timestamp: Option<Cow<'a, str>>, + pub speed_ref: Option<Cow<'a, str>>, + pub speed: Option<Cow<'a, str>>, + pub direction_ref: Option<Cow<'a, str>>, + pub direction: Option<Cow<'a, str>>, + pub destination_bearing_ref: Option<Cow<'a, str>>, + pub destination_bearing: Option<Cow<'a, str>>, + pub positioning_error: Option<Cow<'a, str>>, + pub exposure_time: Option<Cow<'a, str>>, pub f_number: Option<f64>, pub color_space: Option<u8>, pub digital_zoom_ratio: Option<f64>, - pub make: Option<String>, - pub model: Option<String>, - pub lens_make: Option<String>, - pub lens_model: Option<String>, + pub make: Option<Cow<'a, str>>, + pub model: Option<Cow<'a, str>>, + pub lens_make: Option<Cow<'a, str>>, + pub lens_model: Option<Cow<'a, str>>, pub lens_specification: Option<Vec<f64>>, } #[derive(Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] -struct AIDataMiningUsageJSON { - r#use: String, - r#constraint_info: Option<String>, +struct AIDataMiningUsageJSON<'a> { + r#use: Cow<'a, str>, + r#constraint_info: Option<Cow<'a, str>>, } -#[derive(uniffi::Enum)] -pub enum AIDataMiningUsage { +pub enum AIDataMiningUsage<'a> { Allowed, NotAllowed, - Constrained { constraint_info: String }, + Constrained { constraint_info: Cow<'a, str> }, } -#[derive(uniffi::Record)] -pub struct CustomAITrainingOptions { - pub ai_training: AIDataMiningUsage, - pub ai_generative_training: AIDataMiningUsage, - pub data_mining: AIDataMiningUsage, - pub inference: AIDataMiningUsage, +pub struct CustomAITrainingOptions<'a> { + pub ai_training: AIDataMiningUsage<'a>, + pub ai_generative_training: AIDataMiningUsage<'a>, + pub data_mining: AIDataMiningUsage<'a>, + pub inference: AIDataMiningUsage<'a>, } -impl AIDataMiningUsage { +impl AIDataMiningUsage<'_> { fn to_json(&self) -> AIDataMiningUsageJSON { match self { - AIDataMiningUsage::Allowed => { - return AIDataMiningUsageJSON { - r#use: "allowed".to_owned(), - r#constraint_info: None, - }; - } - AIDataMiningUsage::NotAllowed => { - return AIDataMiningUsageJSON { - r#use: "notAllowed".to_owned(), - r#constraint_info: None, - }; - } - AIDataMiningUsage::Constrained { constraint_info } => { - return AIDataMiningUsageJSON { - r#use: "constrained".to_owned(), - r#constraint_info: Some(constraint_info.to_owned()), - }; - } + AIDataMiningUsage::Allowed => AIDataMiningUsageJSON { + r#use: Cow::Borrowed("allowed"), + r#constraint_info: None, + }, + AIDataMiningUsage::NotAllowed => AIDataMiningUsageJSON { + r#use: Cow::Borrowed("notAllowed"), + r#constraint_info: None, + }, + AIDataMiningUsage::Constrained { constraint_info } => AIDataMiningUsageJSON { + r#use: Cow::Borrowed("constrained"), + r#constraint_info: Some(constraint_info.clone()), + }, } } } fn get_creative_work_assertion( - name: String, - identifier: String, - id: String, + name: &str, + identifier: &str, + id: &str, ) -> Result<SchemaDotOrg, SimpleC2PAError> { - let person = SchemaDotOrg::new("Person".to_owned()) + let person = SchemaDotOrg::new("Person".to_string()) .set_default_context() - .insert("name".to_owned(), name.to_owned())? - .insert("identifier".to_owned(), identifier.to_owned())? - .insert("@id".to_owned(), id.to_owned())?; + .insert("name".to_string(), name)? + .insert("identifier".to_string(), identifier)? + .insert("@id".to_string(), id)?; - let work = SchemaDotOrg::new("CreativeWork".to_owned()) + let work = SchemaDotOrg::new("CreativeWork".to_string()) .set_default_context() - .insert("author".to_owned(), vec![person.clone()])?; + .insert("author".to_string(), vec![person])?; Ok(work) } @@ -100,7 +94,6 @@ fn get_actions_assertion(action: String) -> Result<Actions, SimpleC2PAError> { Ok(actions) } -#[uniffi::export] impl ContentCredentials { pub fn add_created_assertion(&self) -> Result<(), SimpleC2PAError> { let actions = get_actions_assertion(c2pa_action::CREATED.to_string())?; @@ -118,22 +111,18 @@ impl ContentCredentials { pub fn add_email_assertion( &self, - email: String, - display_name: String, + _email: String, + _display_name: String, ) -> Result<(), SimpleC2PAError> { Ok(()) } pub fn add_instagram_assertion( &self, - username: String, - display_name: String, + username: &str, + display_name: &str, ) -> Result<(), SimpleC2PAError> { - let work = get_creative_work_assertion( - display_name.to_owned(), - username.to_owned(), - "https://instagram.com".to_owned(), - )?; + let work = get_creative_work_assertion(display_name, username, "https://instagram.com")?; let mut manifest = self.manifest.lock().unwrap(); manifest.add_labeled_assertion(labels::CREATIVE_WORK, &work)?; Ok(()) @@ -141,14 +130,11 @@ impl ContentCredentials { pub fn add_pgp_assertion( &self, - fingerprint: String, - display_name: String, + fingerprint: &str, + display_name: &str, ) -> Result<(), SimpleC2PAError> { - let work = get_creative_work_assertion( - display_name.to_owned(), - fingerprint.to_owned(), - "https://keys.openpgp.org".to_owned(), - )?; + let work = + get_creative_work_assertion(display_name, fingerprint, "https://keys.openpgp.org")?; let mut manifest = self.manifest.lock().unwrap(); manifest.add_labeled_assertion(labels::CREATIVE_WORK, &work)?; Ok(()) @@ -165,46 +151,46 @@ impl ContentCredentials { pub fn add_exif_assertion(&self, exif_data: ExifData) -> Result<(), SimpleC2PAError> { let mut exif = Exif::new(); - if let Some(gps_version_id) = exif_data.gps_version_id.clone() { + if let Some(gps_version_id) = exif_data.gps_version_id { exif = exif.insert("exif:GPSVersionID", gps_version_id)?; } - if let Some(latitude) = exif_data.latitude.clone() { + if let Some(latitude) = exif_data.latitude { exif = exif.insert("exif:GPSLatitude", latitude)?; } - if let Some(longitude) = exif_data.longitude.clone() { + if let Some(longitude) = exif_data.longitude { exif = exif.insert("exif:GPSLongitude", longitude)?; } if let Some(altitude_ref) = exif_data.altitude_ref { exif = exif.insert("exif:GPSAltitudeRef", altitude_ref)?; } - if let Some(altitude) = exif_data.altitude.clone() { + if let Some(altitude) = exif_data.altitude { exif = exif.insert("exif:GPSAltitude", altitude)?; } - if let Some(timestamp) = exif_data.timestamp.clone() { + if let Some(timestamp) = exif_data.timestamp { exif = exif.insert("exif:GPSTimeStamp", timestamp)?; } - if let Some(speed_ref) = exif_data.speed_ref.clone() { + if let Some(speed_ref) = exif_data.speed_ref { exif = exif.insert("exif:GPSSpeedRef", speed_ref)?; } - if let Some(speed) = exif_data.speed.clone() { + if let Some(speed) = exif_data.speed { exif = exif.insert("exif:GPSSpeed", speed)?; } - if let Some(direction_ref) = exif_data.direction_ref.clone() { + if let Some(direction_ref) = exif_data.direction_ref { exif = exif.insert("exif:GPSImgDirectionRef", direction_ref)?; } - if let Some(direction) = exif_data.direction.clone() { + if let Some(direction) = exif_data.direction { exif = exif.insert("exif:GPSImgDirection", direction)?; } - if let Some(destination_bearing_ref) = exif_data.destination_bearing_ref.clone() { + if let Some(destination_bearing_ref) = exif_data.destination_bearing_ref { exif = exif.insert("exif:GPSDestBearingRef", destination_bearing_ref)?; } - if let Some(destination_bearing) = exif_data.destination_bearing.clone() { + if let Some(destination_bearing) = exif_data.destination_bearing { exif = exif.insert("exif:GPSDestBearing", destination_bearing)?; } - if let Some(positioning_error) = exif_data.positioning_error.clone() { + if let Some(positioning_error) = exif_data.positioning_error { exif = exif.insert("exif:GPSHPositioningError", positioning_error)?; } - if let Some(exposure_time) = exif_data.exposure_time.clone() { + if let Some(exposure_time) = exif_data.exposure_time { exif = exif.insert("exif:ExposureTime", exposure_time)?; } if let Some(f_number) = exif_data.f_number { @@ -216,19 +202,19 @@ impl ContentCredentials { if let Some(digital_zoom_ratio) = exif_data.digital_zoom_ratio { exif = exif.insert("exif:DigitalZoomRatio", digital_zoom_ratio)?; } - if let Some(make) = exif_data.make.clone() { + if let Some(make) = exif_data.make { exif = exif.insert("tiff:Make", make)?; } - if let Some(model) = exif_data.model.clone() { + if let Some(model) = exif_data.model { exif = exif.insert("tiff:Model", model)?; } - if let Some(lens_make) = exif_data.lens_make.clone() { + if let Some(lens_make) = exif_data.lens_make { exif = exif.insert("exifEX:LensMake", lens_make)?; } - if let Some(lens_model) = exif_data.lens_model.clone() { + if let Some(lens_model) = exif_data.lens_model { exif = exif.insert("exifEX:LensModel", lens_model)?; } - if let Some(lens_specification) = exif_data.lens_specification.clone() { + if let Some(lens_specification) = exif_data.lens_specification { exif = exif.insert("exifEX:LensSpecification", lens_specification)?; } let mut manifest = self.manifest.lock().unwrap(); @@ -236,7 +222,7 @@ impl ContentCredentials { Ok(()) } - pub fn add_json_assertion(&self, label: String, json: String) -> Result<(), SimpleC2PAError> { + pub fn add_json_assertion(&self, label: &str, json: String) -> Result<(), SimpleC2PAError> { let mut manifest = self.manifest.lock().unwrap(); manifest.add_labeled_assertion(label, &json)?; Ok(()) @@ -277,18 +263,3 @@ impl ContentCredentials { Ok(()) } } -/* -#[cfg(test)] -pub mod tests { - #[test] - fn get_creative_work_assertion() { - let work = crate::assertions::get_creative_work_assertion( - "John Doe".to_owned(), - "johndoe".to_owned(), - "https://instagram.com".to_owned(), - ) - .unwrap(); - assert_eq!("X", "CreativeWork"); - } -} -*/ diff --git a/src/bin/uniffi-bindgen.rs b/src/bin/uniffi-bindgen.rs @@ -1,5 +0,0 @@ -use uniffi; - -fn main() { - uniffi::uniffi_bindgen_main() -} diff --git a/src/certificates.rs b/src/certificates.rs @@ -1,4 +1,6 @@ -use crate::common::{FileData, SimpleC2PAError}; +use std::result::Result; +use std::sync::Arc; + use openssl::asn1::Asn1Integer; use openssl::bn::BigNum; use openssl::ec::{EcGroup, EcKey}; @@ -10,10 +12,9 @@ use openssl::x509::extension::{ }; use openssl::x509::{X509Name, X509NameBuilder, X509}; use ring::rand::SecureRandom; -use std::result::Result; -use std::sync::Arc; -#[uniffi::export] +use crate::common::{FileData, SimpleC2PAError}; + pub fn create_private_key() -> Result<Arc<FileData>, SimpleC2PAError> { let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1)?; let ec_key = EcKey::generate(&group)?; @@ -25,40 +26,36 @@ pub fn create_private_key() -> Result<Arc<FileData>, SimpleC2PAError> { const DEFAULT_ORGANIZATION: &str = "SimpleC2PA"; -#[derive(Debug, Clone, uniffi::Enum)] -pub enum CertificateType { +#[derive(Debug, Clone)] +pub enum CertificateType<'a> { OnlineRoot { - organization: Option<String>, + organization: Option<&'a str>, validity_days: Option<u32>, }, OnlineIntermediate { - organization: Option<String>, + organization: Option<&'a str>, validity_days: Option<u32>, }, OfflineRoot { - organization: Option<String>, + organization: Option<&'a str>, validity_days: Option<u32>, }, OfflineIntermediate { - organization: Option<String>, + organization: Option<&'a str>, validity_days: Option<u32>, }, ContentCredentials { - organization: Option<String>, + organization: Option<&'a str>, validity_days: Option<u32>, }, } -fn format_certificate_name(org: Option<String>, name: String) -> String { - format!( - "{} {}", - org.unwrap_or(DEFAULT_ORGANIZATION.to_owned()), - name - ) +fn format_certificate_name(org: Option<&str>, name: &str) -> String { + format!("{} {}", org.unwrap_or(DEFAULT_ORGANIZATION), name) } -impl CertificateType { - fn is_ca(&self) -> bool { +impl CertificateType<'_> { + const fn is_ca(&self) -> bool { match self { CertificateType::OnlineRoot { .. } => true, CertificateType::OnlineIntermediate { .. } => true, @@ -84,66 +81,65 @@ impl CertificateType { } } - fn to_organization(&self) -> String { + fn to_organization(&self) -> &str { match self { CertificateType::OnlineRoot { organization, .. } => { - organization.clone().unwrap_or(DEFAULT_ORGANIZATION.to_owned()) + organization.unwrap_or(DEFAULT_ORGANIZATION) } CertificateType::OnlineIntermediate { organization, .. } => { - organization.clone().unwrap_or(DEFAULT_ORGANIZATION.to_owned()) + organization.unwrap_or(DEFAULT_ORGANIZATION) } CertificateType::OfflineRoot { organization, .. } => { - organization.clone().unwrap_or(DEFAULT_ORGANIZATION.to_owned()) + organization.unwrap_or(DEFAULT_ORGANIZATION) } CertificateType::OfflineIntermediate { organization, .. } => { - organization.clone().unwrap_or(DEFAULT_ORGANIZATION.to_owned()) + organization.unwrap_or(DEFAULT_ORGANIZATION) } CertificateType::ContentCredentials { organization, .. } => { - organization.clone().unwrap_or(DEFAULT_ORGANIZATION.to_owned()) + organization.unwrap_or(DEFAULT_ORGANIZATION) } } } - + fn to_common_name(&self) -> String { match self { CertificateType::OnlineRoot { organization, .. } => { - format_certificate_name(organization.clone(), "Root CA".to_string()) + format_certificate_name(*organization, "Root CA") } CertificateType::OnlineIntermediate { organization, .. } => { - format_certificate_name(organization.clone(), "Intermediate CA".to_string()) + format_certificate_name(*organization, "Intermediate CA") } CertificateType::OfflineRoot { organization, .. } => { - format_certificate_name(organization.clone(), "Offline Root CA".to_string()) + format_certificate_name(*organization, "Offline Root CA") } CertificateType::OfflineIntermediate { organization, .. } => { - format_certificate_name(organization.clone(), "Offline Intermediate CA".to_string()) + format_certificate_name(*organization, "Offline Intermediate CA") } CertificateType::ContentCredentials { organization, .. } => { - format_certificate_name(organization.clone(), "Content Credentials".to_string()) + format_certificate_name(*organization, "Content Credentials") } } } } -#[derive(Clone, Debug, uniffi::Object)] -pub struct CertificateOptions { +#[derive(Clone, Debug)] +pub struct CertificateOptions<'a> { key: Arc<FileData>, - certificate_type: CertificateType, + certificate_type: CertificateType<'a>, parent_certificate: Option<Arc<Certificate>>, - email_address: Option<String>, - pgp_fingerprint: Option<String>, + email_address: Option<&'a str>, + #[allow(dead_code)] + pgp_fingerprint: Option<&'a str>, } -#[uniffi::export] -impl CertificateOptions { - #[uniffi::constructor] - pub fn new( +impl CertificateOptions<'_> { + pub fn new<'a>( key: Arc<FileData>, - certificate_type: CertificateType, + certificate_type: CertificateType<'a>, parent_certificate: Option<Arc<Certificate>>, - email_address: Option<String>, - pgp_fingerprint: Option<String>, - ) -> Arc<CertificateOptions> { + email_address: Option<&'a str>, + pgp_fingerprint: Option<&'a str>, + ) -> Arc<CertificateOptions<'a>> { Arc::new(CertificateOptions { key, certificate_type, @@ -154,16 +150,15 @@ impl CertificateOptions { } } -#[derive(Clone, Debug, uniffi::Object)] +#[derive(Clone, Debug)] pub struct Certificate { certificate_data: Arc<FileData>, private_key_data: Arc<FileData>, + #[allow(dead_code)] parent_certificate: Option<Arc<Certificate>>, } -#[uniffi::export] impl Certificate { - #[uniffi::constructor] pub fn new( certificate_data: Arc<FileData>, private_key_data: Arc<FileData>, @@ -177,11 +172,11 @@ impl Certificate { } pub fn get_certificate_bytes(&self) -> Result<Vec<u8>, SimpleC2PAError> { - return self.certificate_data.get_bytes(); + self.certificate_data.get_bytes() } pub fn get_private_key_bytes(&self) -> Result<Vec<u8>, SimpleC2PAError> { - return self.private_key_data.get_bytes(); + self.private_key_data.get_bytes() } } fn generate_serial_number() -> Result<Asn1Integer, SimpleC2PAError> { @@ -191,36 +186,35 @@ fn generate_serial_number() -> Result<Asn1Integer, SimpleC2PAError> { let serial_number_bignum = BigNum::from_slice(&serial_number_bytes)?; let serial_number = serial_number_bignum.to_asn1_integer()?; - return Ok(serial_number); + Ok(serial_number) } -fn create_name(options: Arc<CertificateOptions>) -> Result<X509Name, SimpleC2PAError> { +fn create_name(options: &Arc<CertificateOptions>) -> Result<X509Name, SimpleC2PAError> { let mut name_builder = X509NameBuilder::new()?; name_builder.append_entry_by_text("CN", &options.certificate_type.to_common_name())?; - name_builder.append_entry_by_text("O", &options.certificate_type.to_organization())?; + name_builder.append_entry_by_text("O", options.certificate_type.to_organization())?; - if let Some(email_address) = options.email_address.clone() { - name_builder.append_entry_by_text("emailAddress", &email_address)?; + if let Some(email_address) = options.email_address { + name_builder.append_entry_by_text("emailAddress", email_address)?; } let name = name_builder.build(); - return Ok(name); + Ok(name) } -#[uniffi::export] pub fn create_certificate( options: Arc<CertificateOptions>, ) -> Result<Arc<Certificate>, SimpleC2PAError> { let serial_number = generate_serial_number()?; let private_key = PKey::private_key_from_pem(&options.key.get_bytes()?)?; let is_ca = options.certificate_type.is_ca(); - let name = create_name(options.clone())?; + let name = create_name(&options)?; let mut cert_builder = X509::builder()?; cert_builder.set_version(2)?; cert_builder.set_subject_name(&name)?; - if let Some(parent_certificate) = options.parent_certificate.clone() { + if let Some(parent_certificate) = &options.parent_certificate { let parent_cert = X509::from_pem(&parent_certificate.certificate_data.get_bytes()?)?; cert_builder.set_issuer_name(parent_cert.subject_name())?; } else { @@ -288,9 +282,8 @@ pub fn create_certificate( Ok(certificate) } -#[uniffi::export] pub fn create_root_certificate( - organization: Option<String>, + organization: Option<&str>, validity_days: Option<u32>, ) -> Result<Arc<Certificate>, SimpleC2PAError> { let key = create_private_key().unwrap(); @@ -308,10 +301,9 @@ pub fn create_root_certificate( Ok(certificate) } -#[uniffi::export] pub fn create_content_credentials_certificate( root_certificate: Option<Arc<Certificate>>, - organization: Option<String>, + organization: Option<&str>, validity_days: Option<u32>, ) -> Result<Arc<Certificate>, SimpleC2PAError> { let key = create_private_key().unwrap(); @@ -329,61 +321,8 @@ pub fn create_content_credentials_certificate( Ok(certificate) } -#[uniffi::export] pub fn request_signed_certificate( _options: Arc<CertificateOptions>, ) -> Result<String, SimpleC2PAError> { Ok("not yet implemented".to_string()) } - -/* -pub fn create_certificate_signing_request(params: CertificateParams) -> Result<String> { - let private_key = PKey::private_key_from_pem(params.key.as_bytes())?; - - let name = create_name(params)?; - - let mut csr_builder = X509Req::builder()?; - csr_builder.set_version(2)?; - csr_builder.set_subject_name(&name)?; - csr_builder.set_pubkey(&private_key)?; - csr_builder.sign(&private_key, MessageDigest::sha512())?; - let csr = csr_builder.build(); - let pem = csr.to_pem()?; - - return Ok(String::from_utf8(pem)?); -} - -pub fn request_content_credentials_certificate() -> Result<String> { - return Ok("not yet implemented".to_string()); -} - -pub fn create_certificate_from_signing_request(csr_pem: String) -> Result<String> { - let csr = X509Req::from_pem(csr_pem.as_bytes()).expect("Failed to decode CSR"); - let ca_key_pem = include_str!("../test_keys/proofmode.pem"); - let ca_privkey = - PKey::private_key_from_pem(ca_key_pem.as_bytes()).expect("Failed to decode private key"); - - csr.to_text() - .unwrap() - .lines() - .for_each(|line| println!("{:?}", line)); - // let ca_cert_pem = include_str!("../test_keys/proofmode.pub"); - // let ca_cert = X509::from_pem(ca_cert_pem.as_bytes()).expect("Failed to decode CA certificate"); - - let mut builder = X509::builder().expect("Failed to create X509 Builder"); - builder - .set_subject_name(csr.subject_name()) - .expect("Failed to set subject name"); - builder - .set_pubkey(&csr.public_key().expect("Failed to get public key")) - .expect("Failed to set public key"); - // Set other required attributes in the builder... - builder - .sign(&ca_privkey, openssl::hash::MessageDigest::sha256()) - .expect("Failed to sign CSR"); - let cert = builder.build(); - let final_cert_pem = cert.to_pem()?; - let final_cert_pem_str = String::from_utf8(final_cert_pem.clone())?; - Ok(final_cert_pem_str) -} -*/ diff --git a/src/common.rs b/src/common.rs @@ -1,23 +1,24 @@ -use openssl::error::ErrorStack; use std::fs; use std::io::Write; +use std::path::PathBuf; use std::result::Result; use std::sync::Arc; + +use openssl::error::ErrorStack; use tempfile::{NamedTempFile, PersistError}; use thiserror::Error; -#[derive(Debug, Clone, uniffi::Object)] +#[derive(Debug, Clone)] pub struct FileData { - path: Option<String>, + path: Option<PathBuf>, bytes: Option<Vec<u8>>, + #[allow(dead_code)] file_name: Option<String>, } -#[uniffi::export] impl FileData { - #[uniffi::constructor] pub fn new( - path: Option<String>, + path: Option<PathBuf>, bytes: Option<Vec<u8>>, file_name: Option<String>, ) -> Arc<Self> { @@ -37,33 +38,29 @@ impl FileData { return Ok(fs::read(path)?); } - return Err(SimpleC2PAError::Failure { + Err(SimpleC2PAError::Failure { message: "No bytes or path".to_owned(), - }); + }) } - pub fn get_path(&self) -> Result<String, SimpleC2PAError> { - if let Some(path) = &self.path { + pub fn get_path(&self) -> Result<PathBuf, SimpleC2PAError> { + if let Some(ref path) = self.path { return Ok(path.clone()); } if let Some(bytes) = &self.bytes { let mut file = NamedTempFile::new()?; file.write_all(bytes)?; - let file_name = &self.file_name.clone().unwrap_or("file".to_owned()); - let path = format!("/tmp/{}", file_name); - file.persist(path.clone())?; - return Ok(path.clone()); + return Ok(file.path().into()); } - return Err(SimpleC2PAError::Failure { + Err(SimpleC2PAError::Failure { message: "No bytes or path".to_owned(), - }); + }) } } -#[derive(Error, Debug, uniffi::Error)] -#[uniffi(flat_error)] +#[derive(Error, Debug)] pub enum SimpleC2PAError { #[error("Failed with message: {message}")] Failure { message: String }, diff --git a/src/content_credentials.rs b/src/content_credentials.rs @@ -1,26 +1,27 @@ -use crate::certificates::Certificate; -use crate::common::{FileData, SimpleC2PAError}; -use c2pa::{create_signer, Ingredient, Manifest, SigningAlg}; -use log::debug; use std::fmt::{Display, Formatter, Result as FmtResult}; +use std::path::PathBuf; use std::result::Result; use std::sync::{Arc, Mutex}; use std::vec; -use tempfile::NamedTempFile; + +use c2pa::{create_signer, Ingredient, Manifest, SigningAlg}; +use tracing::{debug, info}; +use tracing::error; + +use crate::certificates::Certificate; +use crate::common::{FileData, SimpleC2PAError}; const APPLICATION_NAME: &str = "Simple-C2PA"; const APPLICATION_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[derive(Debug, Clone, uniffi::Object)] +#[derive(Debug, Clone)] pub struct ApplicationInfo { pub name: String, pub version: String, pub icon_uri: Option<String>, } -#[uniffi::export] impl ApplicationInfo { - #[uniffi::constructor] pub fn new(name: String, version: String, icon_uri: Option<String>) -> Arc<Self> { Arc::new(ApplicationInfo { name, @@ -36,17 +37,16 @@ impl Display for ApplicationInfo { } } -#[derive(Debug, uniffi::Object)] +#[derive(Debug)] pub struct ContentCredentials { certificate: Arc<Certificate>, file: Arc<FileData>, + #[allow(dead_code)] application_info: Arc<ApplicationInfo>, pub(crate) manifest: Mutex<Manifest>, } -#[uniffi::export] impl ContentCredentials { - #[uniffi::constructor] pub fn new( certificate: Arc<Certificate>, file: Arc<FileData>, @@ -58,11 +58,11 @@ impl ContentCredentials { None, )); let path = file.get_path().unwrap(); - println!("{:?}", path); - let mut ingredient = Ingredient::from_file(path).unwrap(); - ingredient - .set_thumbnail("image/jpeg", file.get_bytes().unwrap()) - .unwrap(); + let ingredient = Ingredient::from_file(path).unwrap(); + // TODO: We shouldnt load it into bytes here + // ingredient + // .set_thumbnail("image/jpeg", file.get_bytes().unwrap()) + // .unwrap(); let claim_generator = app_info.to_string(); let mut manifest = Manifest::new(claim_generator); manifest.set_parent(ingredient).unwrap(); @@ -77,8 +77,8 @@ impl ContentCredentials { fn sign_manifest_with_certificate( &self, - certificate: Arc<Certificate>, - output_file: Arc<FileData>, + certificate: &Arc<Certificate>, + output_file: &Arc<FileData>, ) -> Result<(), SimpleC2PAError> { let cert = certificate.get_certificate_bytes()?; let pkey = certificate.get_private_key_bytes()?; @@ -92,9 +92,9 @@ impl ContentCredentials { SigningAlg::Ed25519, ]; for alg in algorithms { - debug!("Trying algorithm {:?}... ", alg); + info!("Trying algorithm {:?}... ", alg); let signer = create_signer::from_keys(&cert, &pkey, alg, None); - println!("embedding manifest using signer"); + info!("embedding manifest using signer"); match signer { Ok(signer) => { let mut manifest = self.manifest.lock().unwrap(); @@ -104,17 +104,17 @@ impl ContentCredentials { signer.as_ref(), ) { Ok(_) => { - println!("Using provided certificate and private key"); + debug!("Using provided certificate and private key"); break; } Err(err) => { - debug!("failed: {}\n", err); + error!("failed: {}\n", err); continue; } } } Err(err) => { - println!("failed: {}\n", err); + error!("failed: {}\n", err); continue; } }; @@ -125,30 +125,28 @@ impl ContentCredentials { fn sign_manifest( &self, embed: bool, - output_path: Option<String>, + output_path: Option<PathBuf>, ) -> Result<Arc<FileData>, SimpleC2PAError> { - let temp_path = NamedTempFile::new()?.path().to_path_buf(); - // let output_path = PathBuf::from(output_path.clone()) // .unwrap_or(temp_path); - let output_file = FileData::new(output_path.clone(), None, None); + let output_file = FileData::new(output_path, None, None); if !embed { let mut manifest = self.manifest.lock().unwrap(); manifest.set_sidecar_manifest(); } - self.sign_manifest_with_certificate(self.certificate.clone(), output_file.clone())?; + self.sign_manifest_with_certificate(&self.certificate, &output_file)?; Ok(output_file) } pub fn embed_manifest( &self, - output_path: Option<String>, + output_path: Option<PathBuf>, ) -> Result<Arc<FileData>, SimpleC2PAError> { self.sign_manifest(true, output_path) } pub fn export_manifest( &self, - output_path: Option<String>, + output_path: Option<PathBuf>, ) -> Result<Arc<FileData>, SimpleC2PAError> { self.sign_manifest(false, output_path) } diff --git a/src/lib.rs b/src/lib.rs @@ -1,13 +1,14 @@ +#![warn(clippy::missing_const_for_fn)] + pub use assertions::{AIDataMiningUsage, CustomAITrainingOptions, ExifData}; pub use certificates::{ - Certificate, CertificateOptions, CertificateType, create_certificate, - create_content_credentials_certificate, create_private_key, create_root_certificate, request_signed_certificate, + create_certificate, create_content_credentials_certificate, create_private_key, + create_root_certificate, request_signed_certificate, Certificate, CertificateOptions, + CertificateType, }; pub use common::FileData; pub use content_credentials::{ApplicationInfo, ContentCredentials}; -uniffi::setup_scaffolding!("simple_c2pa"); - mod common; mod certificates; @@ -15,4 +16,3 @@ mod certificates; mod content_credentials; mod assertions; - diff --git a/tests/examples.rs b/tests/examples.rs @@ -38,9 +38,12 @@ pub mod tests { let root_path = "outputs/c2pa-root-certificate.crt"; fs::write(root_path, root_bytes).expect("Can't write file"); - let content_credentials_certificate = - create_content_credentials_certificate(Some(root_certificate.clone()), Some(organization.clone()), None) - .unwrap(); + let content_credentials_certificate = create_content_credentials_certificate( + Some(root_certificate.clone()), + Some(organization.clone()), + None, + ) + .unwrap(); let content_bytes = content_credentials_certificate .get_certificate_bytes() .unwrap(); diff --git a/uniffi.toml b/uniffi.toml @@ -1,5 +0,0 @@ -[bindings.swift] -module_name = "SimpleC2PA" - -[bindings.kotlin] -package_name = "info.guardianproject.simple_c2pa"