11use std:: io:: { Read , Write } ;
22use std:: ops:: { Deref , DerefMut } ;
33
4+ use foreign_types:: ForeignTypeRef ;
5+ use openssl_macros:: corresponds;
6+
47use crate :: dh:: Dh ;
58use crate :: error:: ErrorStack ;
69use crate :: ssl:: {
710 HandshakeError , Ssl , SslContext , SslContextBuilder , SslContextRef , SslMethod , SslMode ,
811 SslOptions , SslRef , SslStream , SslVerifyMode ,
912} ;
10- use crate :: version;
13+ use crate :: { cvt , version} ;
1114use std:: net:: IpAddr ;
1215
1316use super :: MidHandshakeSslStream ;
@@ -24,13 +27,13 @@ ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
2427" ;
2528
2629enum ContextType {
27- WithMethod ( SslMethod )
30+ WithMethod ( SslMethod ) ,
2831}
2932
3033#[ allow( clippy:: inconsistent_digit_grouping) ]
3134fn ctx ( ty : ContextType ) -> Result < SslContextBuilder , ErrorStack > {
3235 let mut ctx = match ty {
33- ContextType :: WithMethod ( method) => SslContextBuilder :: new ( method)
36+ ContextType :: WithMethod ( method) => SslContextBuilder :: new ( method) ,
3437 } ?;
3538
3639 let mut opts = SslOptions :: ALL
@@ -256,6 +259,63 @@ impl ConnectConfiguration {
256259 }
257260}
258261
262+ impl ConnectConfiguration {
263+ /// Enables or disables ECH grease.
264+ ///
265+ /// # Arguments
266+ ///
267+ /// * `enable` - A boolean indicating whether to enable ECH grease.
268+ ///
269+ /// # Safety
270+ ///
271+ /// This function is unsafe because it calls an FFI function.
272+ #[ corresponds( SSL_set_enable_ech_grease ) ]
273+ pub fn set_enable_ech_grease ( & mut self , enable : bool ) {
274+ unsafe { ffi:: SSL_set_enable_ech_grease ( self . as_ptr ( ) , enable as _ ) }
275+ }
276+
277+ /// Adds application settings.
278+ ///
279+ /// # Arguments
280+ ///
281+ /// * `alps` - A slice of bytes representing the application settings.
282+ ///
283+ /// # Returns
284+ ///
285+ /// * `Result<(), ErrorStack>` - Returns `Ok(())` if the operation is successful, otherwise returns an `ErrorStack`.
286+ ///
287+ /// # Safety
288+ ///
289+ /// This function is unsafe because it calls an FFI function.
290+ #[ corresponds( SSL_add_application_settings ) ]
291+ pub fn add_application_settings ( & mut self , alps : & [ u8 ] ) -> Result < ( ) , ErrorStack > {
292+ unsafe {
293+ cvt ( ffi:: SSL_add_application_settings (
294+ self . as_ptr ( ) ,
295+ alps. as_ptr ( ) ,
296+ alps. len ( ) ,
297+ std:: ptr:: null ( ) ,
298+ 0 ,
299+ ) )
300+ . map ( |_| ( ) )
301+ }
302+ }
303+
304+ /// Sets the ALPS use new codepoint flag.
305+ ///
306+ /// # Arguments
307+ ///
308+ /// * `use_new` - A boolean indicating whether to use the new codepoint.
309+ ///
310+ /// # Safety
311+ ///
312+ /// This function is unsafe because it calls an FFI function.
313+ #[ corresponds( SSL_set_alps_use_new_codepoint ) ]
314+ pub fn set_alps_use_new_codepoint ( & mut self , use_new : bool ) {
315+ unsafe { ffi:: SSL_set_alps_use_new_codepoint ( self . as_ptr ( ) , use_new as _ ) }
316+ }
317+ }
318+
259319impl Deref for ConnectConfiguration {
260320 type Target = SslRef ;
261321
0 commit comments