some work towards channel binding support (SCRAM-SHA-{1,256}-PLUS)

This commit is contained in:
lumi 2017-02-25 03:43:11 +01:00
commit c09e8ac06e
5 changed files with 82 additions and 68 deletions

View file

@ -3,26 +3,26 @@
use sasl::SaslMechanism;
pub struct Plain {
name: String,
username: String,
password: String,
}
impl Plain {
pub fn new<N: Into<String>, P: Into<String>>(name: N, password: P) -> Plain {
pub fn new<N: Into<String>, P: Into<String>>(username: N, password: P) -> Plain {
Plain {
name: name.into(),
username: username.into(),
password: password.into(),
}
}
}
impl SaslMechanism for Plain {
fn name() -> &'static str { "PLAIN" }
fn name(&self) -> &str { "PLAIN" }
fn initial(&mut self) -> Result<Vec<u8>, String> {
let mut auth = Vec::new();
auth.push(0);
auth.extend(self.name.bytes());
auth.extend(self.username.bytes());
auth.push(0);
auth.extend(self.password.bytes());
Ok(auth)