@@ -10,7 +10,6 @@ use crate::split::{SplitState, SplitStateContainer};
10
10
use crate :: write_buffer:: WriteBuffer ;
11
11
use embedded_io:: Error as _;
12
12
use embedded_io:: { BufRead , ErrorType , Read , Write } ;
13
- use rand_core:: { CryptoRng , RngCore } ;
14
13
15
14
pub use crate :: config:: * ;
16
15
#[ cfg( feature = "std" ) ]
@@ -70,16 +69,20 @@ where
70
69
///
71
70
/// Returns an error if the handshake does not proceed. If an error occurs, the connection
72
71
/// instance must be recreated.
73
- pub fn open < ' v , RNG , Verifier > (
72
+ pub fn open < ' v , Provider > (
74
73
& mut self ,
75
- context : TlsContext < ' v , CipherSuite , RNG > ,
74
+ mut context : TlsContext < ' v , Provider > ,
76
75
) -> Result < ( ) , TlsError >
77
76
where
78
- RNG : CryptoRng + RngCore ,
79
- Verifier : TlsVerifier < ' v , CipherSuite > ,
77
+ Provider : CryptoProvider < CipherSuite = CipherSuite > ,
80
78
{
81
- let mut handshake: Handshake < CipherSuite , Verifier > =
82
- Handshake :: new ( Verifier :: new ( context. config . server_name ) ) ;
79
+ let mut handshake: Handshake < CipherSuite > = Handshake :: new ( ) ;
80
+ if let ( Ok ( verifier) , Some ( server_name) ) = (
81
+ context. crypto_provider . verifier ( ) ,
82
+ context. config . server_name ,
83
+ ) {
84
+ verifier. set_hostname_verification ( server_name) ?;
85
+ }
83
86
let mut state = State :: ClientHello ;
84
87
85
88
while state != State :: ApplicationData {
90
93
& mut self . record_write_buf ,
91
94
& mut self . key_schedule ,
92
95
context. config ,
93
- context. rng ,
96
+ & mut context. crypto_provider ,
94
97
) ?;
95
98
trace ! ( "State {:?} -> {:?}" , state, next_state) ;
96
99
state = next_state;
0 commit comments