sasl: Use the right name for SCRAM with channel binding

It is SCRAM-SHA-1-PLUS, not SCRAM-SHA-1.
This commit is contained in:
Emmanuel Gil Peyrot 2023-10-25 19:31:04 +02:00
parent faabc2984a
commit b94d1b5222

View file

@ -24,6 +24,7 @@ enum ScramState {
/// A struct for the SASL SCRAM-* and SCRAM-*-PLUS mechanisms. /// A struct for the SASL SCRAM-* and SCRAM-*-PLUS mechanisms.
pub struct Scram<S: ScramProvider> { pub struct Scram<S: ScramProvider> {
name: String, name: String,
name_plus: String,
username: String, username: String,
password: Password, password: Password,
client_nonce: String, client_nonce: String,
@ -45,6 +46,7 @@ impl<S: ScramProvider> Scram<S> {
) -> Result<Scram<S>, Error> { ) -> Result<Scram<S>, Error> {
Ok(Scram { Ok(Scram {
name: format!("SCRAM-{}", S::name()), name: format!("SCRAM-{}", S::name()),
name_plus: format!("SCRAM-{}-PLUS", S::name()),
username: username.into(), username: username.into(),
password: password.into(), password: password.into(),
client_nonce: generate_nonce()?, client_nonce: generate_nonce()?,
@ -64,6 +66,7 @@ impl<S: ScramProvider> Scram<S> {
) -> Scram<S> { ) -> Scram<S> {
Scram { Scram {
name: format!("SCRAM-{}", S::name()), name: format!("SCRAM-{}", S::name()),
name_plus: format!("SCRAM-{}-PLUS", S::name()),
username: username.into(), username: username.into(),
password: password.into(), password: password.into(),
client_nonce: nonce, client_nonce: nonce,
@ -77,7 +80,10 @@ impl<S: ScramProvider> Scram<S> {
impl<S: ScramProvider> Mechanism for Scram<S> { impl<S: ScramProvider> Mechanism for Scram<S> {
fn name(&self) -> &str { fn name(&self) -> &str {
// TODO: this is quite the workaround… // 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<Scram<S>, MechanismError> { fn from_credentials(credentials: Credentials) -> Result<Scram<S>, MechanismError> {