xmpp-rs/sasl/src/secret.rs

43 lines
953 B
Rust
Raw Normal View History

2017-03-25 22:45:30 +00:00
pub trait Secret {}
2017-03-25 22:45:30 +00:00
pub trait Pbkdf2Secret {
fn salt(&self) -> &[u8];
fn iterations(&self) -> usize;
fn digest(&self) -> &[u8];
}
2017-03-25 22:45:30 +00:00
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Plain(pub String);
2017-03-25 22:45:30 +00:00
impl Secret for Plain {}
2017-03-25 22:45:30 +00:00
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Pbkdf2Sha1 {
pub salt: Vec<u8>,
pub iterations: usize,
pub digest: Vec<u8>,
}
2017-03-25 22:45:30 +00:00
impl Secret for Pbkdf2Sha1 {}
2017-03-25 22:45:30 +00:00
impl Pbkdf2Secret for Pbkdf2Sha1 {
fn salt(&self) -> &[u8] { &self.salt }
fn iterations(&self) -> usize { self.iterations }
fn digest(&self) -> &[u8] { &self.digest }
}
2017-03-25 22:45:30 +00:00
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Pbkdf2Sha256 {
pub salt: Vec<u8>,
pub iterations: usize,
pub digest: Vec<u8>,
}
2017-03-25 22:45:30 +00:00
impl Secret for Pbkdf2Sha256 {}
2017-03-25 22:45:30 +00:00
impl Pbkdf2Secret for Pbkdf2Sha256 {
fn salt(&self) -> &[u8] { &self.salt }
fn iterations(&self) -> usize { self.iterations }
fn digest(&self) -> &[u8] { &self.digest }
}