Skip to content

Commit 0fe645d

Browse files
authored
chore: Update c2pa-rs version to latest (#83)
* Add deps * WIP * WIP * WIP * chore: FInish update * fix: update c2pa-rs * chore: format * chore: format * chore: up crypto
1 parent 470ee47 commit 0fe645d

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ crate-type = ["lib", "cdylib"]
1212
normal = ["openssl-src"]
1313

1414
[dependencies]
15-
c2pa = {version = "0.40.0", features = ["unstable_api", "file_io", "openssl", "pdf", "fetch_remote_manifests"]}
15+
c2pa = { version = "0.41.1", features = ["unstable_api", "file_io", "openssl", "pdf", "fetch_remote_manifests"]}
16+
c2pa-crypto = {version = "0.3.1" }
1617
thiserror = "1.0.49"
1718
uniffi = "0.28.2"
1819
openssl-src = "=300.3.1" # Required for openssl-sys

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
maturin==1.7.4
22
uniffi-bindgen==0.28.0
3-
cryptography==43.0.1
3+
cryptography==44.0.0
4+
pytest==8.3.4

src/callback_signer.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// each license.
1212

1313
use c2pa::{Signer, SigningAlg};
14+
// RawSigner is currently used only fully qualified
15+
use c2pa_crypto::{raw_signature::RawSignerError, time_stamp::TimeStampProvider};
1416
use log::debug;
1517

1618
use crate::Result;
@@ -34,6 +36,41 @@ pub struct RemoteSigner {
3436
reserve_size: u32,
3537
}
3638

39+
impl TimeStampProvider for RemoteSigner {}
40+
41+
impl c2pa_crypto::raw_signature::RawSigner for RemoteSigner {
42+
fn sign(&self, data: &[u8]) -> std::result::Result<Vec<u8>, RawSignerError> {
43+
let signature_result = self.signer_callback.sign(data.to_vec());
44+
45+
match signature_result {
46+
Ok(signature) => Ok(signature),
47+
Err(e) => Err(c2pa_crypto::raw_signature::RawSignerError::IoError(
48+
e.to_string(),
49+
)),
50+
}
51+
}
52+
53+
fn alg(&self) -> c2pa_crypto::raw_signature::SigningAlg {
54+
match self.alg {
55+
SigningAlg::Es384 => c2pa_crypto::raw_signature::SigningAlg::Es384,
56+
SigningAlg::Es512 => c2pa_crypto::raw_signature::SigningAlg::Es512,
57+
SigningAlg::Ps256 => c2pa_crypto::raw_signature::SigningAlg::Ps256,
58+
SigningAlg::Ps384 => c2pa_crypto::raw_signature::SigningAlg::Ps384,
59+
SigningAlg::Ps512 => c2pa_crypto::raw_signature::SigningAlg::Ps512,
60+
SigningAlg::Ed25519 => c2pa_crypto::raw_signature::SigningAlg::Ed25519,
61+
SigningAlg::Es256 => c2pa_crypto::raw_signature::SigningAlg::Es256,
62+
}
63+
}
64+
65+
fn cert_chain(&self) -> std::result::Result<Vec<Vec<u8>>, RawSignerError> {
66+
Ok(Vec::new())
67+
}
68+
69+
fn reserve_size(&self) -> usize {
70+
self.reserve_size as usize
71+
}
72+
}
73+
3774
impl Signer for RemoteSigner {
3875
fn sign(&self, data: &[u8]) -> c2pa::Result<Vec<u8>> {
3976
self.signer_callback
@@ -57,6 +94,10 @@ impl Signer for RemoteSigner {
5794
fn direct_cose_handling(&self) -> bool {
5895
true
5996
}
97+
98+
fn raw_signer(&self) -> Box<&dyn c2pa_crypto::raw_signature::RawSigner> {
99+
Box::new(self)
100+
}
60101
}
61102

62103
impl CallbackSigner {

0 commit comments

Comments
 (0)