@@ -18,7 +18,10 @@ use std::{
1818 fs:: File ,
1919 io:: { BufReader , Read , Write } ,
2020 path:: Path ,
21- sync:: { Arc , atomic:: { AtomicU32 , Ordering } } ,
21+ sync:: {
22+ atomic:: { AtomicU32 , Ordering } ,
23+ Arc ,
24+ } ,
2225} ;
2326use veracruz_utils:: VERACRUZ_RUNTIME_HASH_EXTENSION_ID ;
2427
@@ -99,7 +102,8 @@ impl Write for InsecureConnection {
99102 let received_session_id = body_items[ 0 ]
100103 . parse :: < u32 > ( )
101104 . map_err ( |_| err ( "bad session id" ) ) ?;
102- self . remote_session_id . store ( received_session_id, Ordering :: SeqCst ) ;
105+ self . remote_session_id
106+ . store ( received_session_id, Ordering :: SeqCst ) ;
103107 // And append response data to the read_buffer.
104108 for item in body_items. iter ( ) . skip ( 1 ) {
105109 let this_body_data = base64:: decode ( item) . map_err ( |_| err ( "base64::decode" ) ) ?;
@@ -153,7 +157,11 @@ impl VeracruzClient {
153157 pub ( crate ) fn read_private_key < P : AsRef < Path > > ( filename : P ) -> Result < Pk > {
154158 let mut buffer = VeracruzClient :: read_all_bytes_in_file ( filename) ?;
155159 buffer. push ( b'\0' ) ;
156- let pkey_vec = Pk :: from_private_key ( & buffer, None ) ?;
160+ let pkey_vec = Pk :: from_private_key (
161+ & mut mbedtls:: rng:: CtrDrbg :: new ( Arc :: new ( mbedtls:: rng:: OsEntropy :: new ( ) ) , None ) ?,
162+ & buffer,
163+ None ,
164+ ) ?;
157165 Ok ( pkey_vec)
158166 }
159167
@@ -228,8 +236,8 @@ impl VeracruzClient {
228236
229237 use mbedtls:: ssl:: config:: { Config , Endpoint , Preset , Transport , Version } ;
230238 let mut config = Config :: new ( Endpoint :: Client , Transport :: Stream , Preset :: Default ) ;
231- config. set_min_version ( Version :: Tls1_2 ) ?;
232- config. set_max_version ( Version :: Tls1_2 ) ?;
239+ config. set_min_version ( Version :: Tls1_3 ) ?;
240+ config. set_max_version ( Version :: Tls1_3 ) ?;
233241 let policy_ciphersuite = veracruz_utils:: lookup_ciphersuite ( policy. ciphersuite ( ) . as_str ( ) )
234242 . ok_or ( anyhow ! ( VeracruzClientError :: UnexpectedCiphersuite ) ) ?;
235243 let cipher_suites: Vec < i32 > = vec ! [ policy_ciphersuite. into( ) , 0 ] ;
@@ -372,12 +380,13 @@ impl VeracruzClient {
372380 . ok_or ( anyhow ! ( VeracruzClientError :: UnexpectedCertificate ) ) ?;
373381 let extensions = cert. extensions ( ) ?;
374382 // check for OUR extension
375- let data = veracruz_utils:: find_extension ( extensions, & VERACRUZ_RUNTIME_HASH_EXTENSION_ID ) . ok_or ( {
376- error ! ( "Our extension is not present. This should be fatal" ) ;
377- anyhow ! ( VeracruzClientError :: RuntimeHashExtensionMissing )
378- } ) ?;
383+ let data = veracruz_utils:: find_extension ( extensions, & VERACRUZ_RUNTIME_HASH_EXTENSION_ID )
384+ . ok_or ( {
385+ error ! ( "Our extension is not present. This should be fatal" ) ;
386+ anyhow ! ( VeracruzClientError :: RuntimeHashExtensionMissing )
387+ } ) ?;
379388 info ! ( "Certificate extension present." ) ;
380- self . compare_runtime_hash ( & data) . map_err ( |err|{
389+ self . compare_runtime_hash ( & data) . map_err ( |err| {
381390 error ! ( "Runtime hash mismatch: {}." , err) ;
382391 anyhow ! ( err)
383392 } )
0 commit comments