Skip to content

Commit 5b52d70

Browse files
committed
WIP
1 parent dc32386 commit 5b52d70

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed

Cargo.toml

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

1414
[dependencies]
15-
c2pa = {version = "0.41.0", features = ["unstable_api", "file_io", "openssl", "pdf", "fetch_remote_manifests"]}
15+
c2pa = { git = "https://github.com/contentauth/c2pa-rs.git", branch="mathern/python-tradeoffs", features = ["unstable_api", "file_io", "openssl", "pdf", "fetch_remote_manifests"]}
1616
c2pa-crypto = {version = "0.3.0" }
1717
thiserror = "1.0.49"
1818
uniffi = "0.28.2"

src/callback_signer.rs

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
// each license.
1212

1313
use c2pa::{Signer, SigningAlg};
14-
use c2pa_crypto::raw_signature::RawSigner;
14+
use c2pa_crypto::{
15+
raw_signature::{RawSigner, RawSignerError},
16+
time_stamp::TimeStampProvider,
17+
};
1518
use log::debug;
1619

1720
use crate::Result;
@@ -35,6 +38,46 @@ pub struct RemoteSigner {
3538
reserve_size: u32,
3639
}
3740

41+
impl TimeStampProvider for RemoteSigner {}
42+
43+
impl c2pa_crypto::raw_signature::RawSigner for RemoteSigner {
44+
fn sign(
45+
&self,
46+
data: &[u8],
47+
) -> std::result::Result<Vec<u8>, RawSignerError> {
48+
let signature_result = self.signer_callback.sign(data.to_vec());
49+
50+
match signature_result {
51+
Ok(signature) => Ok(signature),
52+
Err(e) => Err(c2pa_crypto::raw_signature::RawSignerError::IoError(
53+
e.to_string(),
54+
)),
55+
}
56+
}
57+
58+
fn alg(&self) -> c2pa_crypto::raw_signature::SigningAlg {
59+
match self.alg {
60+
SigningAlg::Es256 => c2pa_crypto::raw_signature::SigningAlg::Es256,
61+
SigningAlg::Es384 => c2pa_crypto::raw_signature::SigningAlg::Es384,
62+
SigningAlg::Es512 => c2pa_crypto::raw_signature::SigningAlg::Es512,
63+
SigningAlg::Ps256 => c2pa_crypto::raw_signature::SigningAlg::Ps256,
64+
SigningAlg::Ps384 => c2pa_crypto::raw_signature::SigningAlg::Ps384,
65+
SigningAlg::Ps512 => c2pa_crypto::raw_signature::SigningAlg::Ps512,
66+
SigningAlg::Ed25519 => c2pa_crypto::raw_signature::SigningAlg::Ed25519,
67+
}
68+
}
69+
70+
fn cert_chain(
71+
&self,
72+
) -> std::result::Result<Vec<Vec<u8>>, RawSignerError> {
73+
Ok(Vec::new())
74+
}
75+
76+
fn reserve_size(&self) -> usize {
77+
self.reserve_size as usize
78+
}
79+
}
80+
3881
impl Signer for RemoteSigner {
3982
fn sign(&self, data: &[u8]) -> c2pa::Result<Vec<u8>> {
4083
self.signer_callback

0 commit comments

Comments
 (0)