rustls/server/
common.rs

1use crate::hash_hs;
2use crate::key;
3use crate::msgs::handshake::{ServerExtension, SessionID};
4use crate::session::SessionRandoms;
5use crate::suites;
6
7use std::mem;
8
9pub struct HandshakeDetails {
10    pub transcript: hash_hs::HandshakeHash,
11    pub hash_at_server_fin: Vec<u8>,
12    pub session_id: SessionID,
13    pub randoms: SessionRandoms,
14    pub using_ems: bool,
15    pub extra_exts: Vec<ServerExtension>,
16}
17
18impl HandshakeDetails {
19    pub fn new(extra_exts: Vec<ServerExtension>) -> HandshakeDetails {
20        HandshakeDetails {
21            transcript: hash_hs::HandshakeHash::new(),
22            hash_at_server_fin: Vec::new(),
23            session_id: SessionID::empty(),
24            randoms: SessionRandoms::for_server(),
25            using_ems: false,
26            extra_exts,
27        }
28    }
29}
30
31pub struct ServerKXDetails {
32    pub kx: Option<suites::KeyExchange>,
33}
34
35impl ServerKXDetails {
36    pub fn new(kx: suites::KeyExchange) -> ServerKXDetails {
37        ServerKXDetails { kx: Some(kx) }
38    }
39
40    pub fn take_kx(&mut self) -> suites::KeyExchange {
41        self.kx.take().unwrap()
42    }
43}
44
45pub struct ClientCertDetails {
46    pub cert_chain: Vec<key::Certificate>,
47}
48
49impl ClientCertDetails {
50    pub fn new(chain: Vec<key::Certificate>) -> ClientCertDetails {
51        ClientCertDetails { cert_chain: chain }
52    }
53
54    pub fn take_chain(&mut self) -> Vec<key::Certificate> {
55        mem::replace(&mut self.cert_chain, Vec::new())
56    }
57}