1111// each license.
1212
1313use c2pa:: { Signer , SigningAlg } ;
14- use c2pa_crypto:: raw_signature:: RawSigner ;
14+ use c2pa_crypto:: {
15+ raw_signature:: { RawSigner , RawSignerError } ,
16+ time_stamp:: TimeStampProvider ,
17+ } ;
1518use log:: debug;
1619
1720use 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+
3881impl Signer for RemoteSigner {
3982 fn sign ( & self , data : & [ u8 ] ) -> c2pa:: Result < Vec < u8 > > {
4083 self . signer_callback
0 commit comments