From b94d1b522251e5fee7111af4b520e568b7c4783b Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 25 Oct 2023 19:31:04 +0200 Subject: [PATCH] sasl: Use the right name for SCRAM with channel binding It is SCRAM-SHA-1-PLUS, not SCRAM-SHA-1. --- sasl/src/client/mechanisms/scram.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sasl/src/client/mechanisms/scram.rs b/sasl/src/client/mechanisms/scram.rs index bec1fda..0cad90f 100644 --- a/sasl/src/client/mechanisms/scram.rs +++ b/sasl/src/client/mechanisms/scram.rs @@ -24,6 +24,7 @@ enum ScramState { /// A struct for the SASL SCRAM-* and SCRAM-*-PLUS mechanisms. pub struct Scram { name: String, + name_plus: String, username: String, password: Password, client_nonce: String, @@ -45,6 +46,7 @@ impl Scram { ) -> Result, Error> { Ok(Scram { name: format!("SCRAM-{}", S::name()), + name_plus: format!("SCRAM-{}-PLUS", S::name()), username: username.into(), password: password.into(), client_nonce: generate_nonce()?, @@ -64,6 +66,7 @@ impl Scram { ) -> Scram { Scram { name: format!("SCRAM-{}", S::name()), + name_plus: format!("SCRAM-{}-PLUS", S::name()), username: username.into(), password: password.into(), client_nonce: nonce, @@ -77,7 +80,10 @@ impl Scram { impl Mechanism for Scram { fn name(&self) -> &str { // TODO: this is quite the workaround… - &self.name + match self.channel_binding { + ChannelBinding::None | ChannelBinding::Unsupported => &self.name, + ChannelBinding::TlsUnique(_) | ChannelBinding::TlsExporter(_) => &self.name_plus, + } } fn from_credentials(credentials: Credentials) -> Result, MechanismError> {