File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,13 @@ struct SerializedState {
6565 is_client : bool ,
6666}
6767
68+ #[ derive( Serialize , Deserialize , Debug , Clone ) ]
69+ pub struct KeyLogData {
70+ pub local_random : Vec < u8 > ,
71+ pub remote_random : Vec < u8 > ,
72+ pub master_secret : Vec < u8 > ,
73+ }
74+
6875impl Default for State {
6976 fn default ( ) -> Self {
7077 State {
@@ -249,6 +256,26 @@ impl State {
249256
250257 Ok ( ( ) )
251258 }
259+
260+ /// key_log_data returns the key log data for the current state.
261+ pub fn key_log_data ( & self ) -> Result < KeyLogData > {
262+ let mut local_random = vec ! [ ] ;
263+ {
264+ let mut writer = BufWriter :: < & mut Vec < u8 > > :: new ( local_random. as_mut ( ) ) ;
265+ self . local_random . marshal ( & mut writer) ?;
266+ }
267+ let mut remote_random = vec ! [ ] ;
268+ {
269+ let mut writer = BufWriter :: < & mut Vec < u8 > > :: new ( remote_random. as_mut ( ) ) ;
270+ self . remote_random . marshal ( & mut writer) ?;
271+ }
272+
273+ Ok ( KeyLogData {
274+ local_random,
275+ remote_random,
276+ master_secret : self . master_secret . clone ( ) ,
277+ } )
278+ }
252279}
253280
254281#[ async_trait]
You can’t perform that action at this time.
0 commit comments