ytls_client/client_ctx/c_handshake/
p_wrapped.rs

1//! yTLS Wrapped Record (Handshake) Processor
2
3use crate::TlsClientCtxConfig;
4use ytls_ctx::CtxError;
5use ytls_traits::{CryptoConfig, CryptoRng};
6
7use crate::ClientHandshakeCtx;
8
9use ytls_traits::ServerCertificateProcessor;
10use ytls_traits::ServerCertificateVerifyProcessor;
11use ytls_traits::ServerFinishedProcessor;
12use ytls_traits::ServerWrappedRecordProcessor;
13
14impl<Config, Crypto, Rng> ServerWrappedRecordProcessor for ClientHandshakeCtx<Config, Crypto, Rng>
15where
16    Config: TlsClientCtxConfig,
17    Crypto: CryptoConfig,
18    Rng: CryptoRng,
19{
20    type ServerCertificateHandler = Self;
21    type ServerCertificateVerifyHandler = Self;
22    type ServerFinishedHandler = Self;
23
24    #[inline]
25    fn server_certificate(&mut self) -> &mut Self::ServerCertificateHandler {
26        self
27    }
28    #[inline]
29    fn server_certificate_verify(&mut self) -> &mut Self::ServerCertificateVerifyHandler {
30        self
31    }
32    #[inline]
33    fn server_finished(
34        &mut self,
35    ) -> &mut <Self as ServerWrappedRecordProcessor>::ServerFinishedHandler {
36        self
37    }
38}
39
40impl<Config, Crypto, Rng> ServerCertificateProcessor for ClientHandshakeCtx<Config, Crypto, Rng>
41where
42    Config: TlsClientCtxConfig,
43    Crypto: CryptoConfig,
44    Rng: CryptoRng,
45{
46    #[inline]
47    fn handle_server_certificate(&mut self, _cert_data: &[u8], _ext_data: &[u8]) -> () {
48        //println!("Handle server certificate cert_data: {}, ext_data: {}", hex::encode(cert_data), hex::encode(ext_data));
49    }
50}
51
52impl<Config, Crypto, Rng> ServerCertificateVerifyProcessor
53    for ClientHandshakeCtx<Config, Crypto, Rng>
54where
55    Config: TlsClientCtxConfig,
56    Crypto: CryptoConfig,
57    Rng: CryptoRng,
58{
59    #[inline]
60    fn handle_server_certificate_verify(&mut self, _algorithm: [u8; 2], _signature: &[u8]) -> () {
61        //println!("Handle server certificate verify signature: {}", hex::encode(signature));
62    }
63}
64
65impl<Config, Crypto, Rng> ServerFinishedProcessor for ClientHandshakeCtx<Config, Crypto, Rng>
66where
67    Config: TlsClientCtxConfig,
68    Crypto: CryptoConfig,
69    Rng: CryptoRng,
70{
71    #[inline]
72    fn handle_server_finished(&mut self, _hash_finished: &[u8]) -> () {
73        //println!("Handle server finished: {}", hex::encode(hash_finished));
74    }
75}