11
11
// each license.
12
12
13
13
use c2pa:: { Signer , SigningAlg } ;
14
+ // RawSigner is currently used only fully qualified
15
+ use c2pa_crypto:: { raw_signature:: RawSignerError , time_stamp:: TimeStampProvider } ;
14
16
use log:: debug;
15
17
16
18
use crate :: Result ;
@@ -34,6 +36,41 @@ pub struct RemoteSigner {
34
36
reserve_size : u32 ,
35
37
}
36
38
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
+
37
74
impl Signer for RemoteSigner {
38
75
fn sign ( & self , data : & [ u8 ] ) -> c2pa:: Result < Vec < u8 > > {
39
76
self . signer_callback
@@ -57,6 +94,10 @@ impl Signer for RemoteSigner {
57
94
fn direct_cose_handling ( & self ) -> bool {
58
95
true
59
96
}
97
+
98
+ fn raw_signer ( & self ) -> Box < & dyn c2pa_crypto:: raw_signature:: RawSigner > {
99
+ Box :: new ( self )
100
+ }
60
101
}
61
102
62
103
impl CallbackSigner {
0 commit comments