@@ -144,46 +144,47 @@ fn set_algo_prefs(session: &mut Session, opts: &SshOpts, config: &Config) -> Rem
144144 trace ! ( "compression: {}" , compress) ;
145145 session. set_compress ( compress) ;
146146 }
147- if let Some ( algos ) = params . kex_algorithms . as_deref ( ) {
148- let algos = algos . join ( "," ) ;
149- trace ! ( "Configuring KEX algorithms: {}" , algos ) ;
150- if let Err ( err ) = session . method_pref ( SshMethodType :: Kex , algos. as_str ( ) ) {
151- error ! ( "Could not set KEX algorithms: {}" , err ) ;
152- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
153- }
147+
148+ // kex
149+ let algos = params . kex_algorithms . algorithms ( ) . join ( "," ) ;
150+ trace ! ( "Configuring KEX algorithms: {}" , algos) ;
151+ if let Err ( err ) = session . method_pref ( SshMethodType :: Kex , algos . as_str ( ) ) {
152+ error ! ( "Could not set KEX algorithms: {}" , err) ;
153+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err ) ) ;
154154 }
155- if let Some ( algos ) = params . host_key_algorithms . as_deref ( ) {
156- let algos = algos . join ( "," ) ;
157- trace ! ( "Configuring HostKey algorithms: {}" , algos ) ;
158- if let Err ( err ) = session . method_pref ( SshMethodType :: HostKey , algos. as_str ( ) ) {
159- error ! ( "Could not set host key algorithms: {}" , err ) ;
160- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
161- }
155+
156+ // HostKey
157+ let algos = params . host_key_algorithms . algorithms ( ) . join ( "," ) ;
158+ trace ! ( "Configuring HostKey algorithms: {}" , algos) ;
159+ if let Err ( err ) = session . method_pref ( SshMethodType :: HostKey , algos . as_str ( ) ) {
160+ error ! ( "Could not set host key algorithms: {}" , err) ;
161+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err ) ) ;
162162 }
163- if let Some ( algos) = params. ciphers . as_deref ( ) {
164- let algos = algos. join ( "," ) ;
165- trace ! ( "Configuring Crypt algorithms: {}" , algos) ;
166- if let Err ( err) = session. method_pref ( SshMethodType :: CryptCs , algos. as_str ( ) ) {
167- error ! ( "Could not set crypt algorithms (client-server): {}" , err) ;
168- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
169- }
170- if let Err ( err) = session. method_pref ( SshMethodType :: CryptSc , algos. as_str ( ) ) {
171- error ! ( "Could not set crypt algorithms (server-client): {}" , err) ;
172- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
173- }
163+
164+ // ciphers
165+ let algos = params. ciphers . algorithms ( ) . join ( "," ) ;
166+ trace ! ( "Configuring Crypt algorithms: {}" , algos) ;
167+ if let Err ( err) = session. method_pref ( SshMethodType :: CryptCs , algos. as_str ( ) ) {
168+ error ! ( "Could not set crypt algorithms (client-server): {}" , err) ;
169+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
174170 }
175- if let Some ( algos) = params. mac . as_deref ( ) {
176- let algos = algos. join ( "," ) ;
177- trace ! ( "Configuring MAC algorithms: {}" , algos) ;
178- if let Err ( err) = session. method_pref ( SshMethodType :: MacCs , algos. as_str ( ) ) {
179- error ! ( "Could not set MAC algorithms (client-server): {}" , err) ;
180- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
181- }
182- if let Err ( err) = session. method_pref ( SshMethodType :: MacSc , algos. as_str ( ) ) {
183- error ! ( "Could not set MAC algorithms (server-client): {}" , err) ;
184- return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
185- }
171+ if let Err ( err) = session. method_pref ( SshMethodType :: CryptSc , algos. as_str ( ) ) {
172+ error ! ( "Could not set crypt algorithms (server-client): {}" , err) ;
173+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
186174 }
175+
176+ // MAC
177+ let algos = params. mac . algorithms ( ) . join ( "," ) ;
178+ trace ! ( "Configuring MAC algorithms: {}" , algos) ;
179+ if let Err ( err) = session. method_pref ( SshMethodType :: MacCs , algos. as_str ( ) ) {
180+ error ! ( "Could not set MAC algorithms (client-server): {}" , err) ;
181+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
182+ }
183+ if let Err ( err) = session. method_pref ( SshMethodType :: MacSc , algos. as_str ( ) ) {
184+ error ! ( "Could not set MAC algorithms (server-client): {}" , err) ;
185+ return Err ( RemoteError :: new_ex ( RemoteErrorType :: ProtocolError , err) ) ;
186+ }
187+
187188 // -- configure algos from opts
188189 for method in opts. methods . iter ( ) {
189190 let algos = method. prefs ( ) ;
0 commit comments