From 77460e4a2856e6d139271ccab271996cb0c1e120 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Tue, 25 Feb 2020 23:31:21 +0100 Subject: [PATCH] client: Remove Result from Mechanism::initial(). --- sasl/src/client/mechanisms/plain.rs | 4 ++-- sasl/src/client/mechanisms/scram.rs | 8 ++++---- sasl/src/client/mod.rs | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sasl/src/client/mechanisms/plain.rs b/sasl/src/client/mechanisms/plain.rs index 213fb785..59aed451 100644 --- a/sasl/src/client/mechanisms/plain.rs +++ b/sasl/src/client/mechanisms/plain.rs @@ -39,12 +39,12 @@ impl Mechanism for Plain { } } - fn initial(&mut self) -> Result, String> { + fn initial(&mut self) -> Vec { let mut auth = Vec::new(); auth.push(0); auth.extend(self.username.bytes()); auth.push(0); auth.extend(self.password.bytes()); - Ok(auth) + auth } } diff --git a/sasl/src/client/mechanisms/scram.rs b/sasl/src/client/mechanisms/scram.rs index 58eb2bef..39c1fb66 100644 --- a/sasl/src/client/mechanisms/scram.rs +++ b/sasl/src/client/mechanisms/scram.rs @@ -81,7 +81,7 @@ impl Mechanism for Scram { } } - fn initial(&mut self) -> Result, String> { + fn initial(&mut self) -> Vec { let mut gs2_header = Vec::new(); gs2_header.extend(self.channel_binding.header()); let mut bare = Vec::new(); @@ -93,7 +93,7 @@ impl Mechanism for Scram { data.extend(&gs2_header); data.extend(bare.clone()); self.state = ScramState::SentInitialMessage { initial_message: bare, gs2_header: gs2_header }; - Ok(data) + data } fn response(&mut self, challenge: &[u8]) -> Result, String> { @@ -182,7 +182,7 @@ mod tests { let client_final = b"c=biws,r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,p=v0X8v3Bz2T0CJGbJQyF0X+HI4Ts="; let server_final = b"v=rmF9pqV8S7suAoZWja4dJRkFsKQ="; let mut mechanism = Scram::::new_with_nonce(username, password, client_nonce.to_owned()); - let init = mechanism.initial().unwrap(); + let init = mechanism.initial(); assert_eq!( String::from_utf8(init.clone()).unwrap() , String::from_utf8(client_init[..].to_owned()).unwrap() ); // depends on ordering… let resp = mechanism.response(&server_init[..]).unwrap(); @@ -201,7 +201,7 @@ mod tests { let client_final = b"c=biws,r=rOprNGfwEbeRWgbNEkqO%hvYDpWUa2RaTCAfuxFIlj)hNlF$k0,p=dHzbZapWIk4jUhN+Ute9ytag9zjfMHgsqmmiz7AndVQ="; let server_final = b"v=6rriTRBi23WpRR/wtup+mMhUZUn/dB5nLTJRsjl95G4="; let mut mechanism = Scram::::new_with_nonce(username, password, client_nonce.to_owned()); - let init = mechanism.initial().unwrap(); + let init = mechanism.initial(); assert_eq!( String::from_utf8(init.clone()).unwrap() , String::from_utf8(client_init[..].to_owned()).unwrap() ); // depends on ordering… let resp = mechanism.response(&server_init[..]).unwrap(); diff --git a/sasl/src/client/mod.rs b/sasl/src/client/mod.rs index a6cd093e..2e3f487a 100644 --- a/sasl/src/client/mod.rs +++ b/sasl/src/client/mod.rs @@ -9,8 +9,8 @@ pub trait Mechanism { fn from_credentials(credentials: Credentials) -> Result where Self: Sized; /// Provides initial payload of the SASL mechanism. - fn initial(&mut self) -> Result, String> { - Ok(Vec::new()) + fn initial(&mut self) -> Vec { + Vec::new() } /// Creates a response to the SASL challenge.