Update to Edition 2018.
This commit is contained in:
parent
a0c513f309
commit
03923d4885
11 changed files with 30 additions and 34 deletions
|
@ -9,6 +9,7 @@ documentation = "https://docs.rs/sasl"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["sasl", "authentication"]
|
keywords = ["sasl", "authentication"]
|
||||||
license = "LGPL-3.0+"
|
license = "LGPL-3.0+"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
gitlab = { repository = "lumi/sasl-rs" }
|
gitlab = { repository = "lumi/sasl-rs" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Provides the SASL "ANONYMOUS" mechanism.
|
//! Provides the SASL "ANONYMOUS" mechanism.
|
||||||
|
|
||||||
use client::Mechanism;
|
use crate::client::Mechanism;
|
||||||
use common::{Secret, Credentials};
|
use crate::common::{Secret, Credentials};
|
||||||
|
|
||||||
/// A struct for the SASL ANONYMOUS mechanism.
|
/// A struct for the SASL ANONYMOUS mechanism.
|
||||||
pub struct Anonymous;
|
pub struct Anonymous;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Provides the SASL "PLAIN" mechanism.
|
//! Provides the SASL "PLAIN" mechanism.
|
||||||
|
|
||||||
use client::Mechanism;
|
use crate::client::Mechanism;
|
||||||
use common::{Secret, Credentials, Password, Identity};
|
use crate::common::{Secret, Credentials, Password, Identity};
|
||||||
|
|
||||||
/// A struct for the SASL PLAIN mechanism.
|
/// A struct for the SASL PLAIN mechanism.
|
||||||
pub struct Plain {
|
pub struct Plain {
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
use client::Mechanism;
|
use crate::client::Mechanism;
|
||||||
use common::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity};
|
use crate::common::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity};
|
||||||
use common::scram::{ScramProvider, generate_nonce};
|
use crate::common::scram::{ScramProvider, generate_nonce};
|
||||||
|
|
||||||
use error::Error;
|
use crate::error::Error;
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
@ -168,9 +168,9 @@ impl<S: ScramProvider> Mechanism for Scram<S> {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use client::Mechanism;
|
use crate::client::Mechanism;
|
||||||
use client::mechanisms::Scram;
|
use crate::client::mechanisms::Scram;
|
||||||
use common::scram::{Sha1, Sha256};
|
use crate::common::scram::{Sha1, Sha256};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn scram_sha1_works() { // Source: https://wiki.xmpp.org/web/SASLandSCRAM-SHA-1
|
fn scram_sha1_works() { // Source: https://wiki.xmpp.org/web/SASLandSCRAM-SHA-1
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use common::Credentials;
|
use crate::common::Credentials;
|
||||||
|
|
||||||
/// A trait which defines SASL mechanisms.
|
/// A trait which defines SASL mechanisms.
|
||||||
pub trait Mechanism {
|
pub trait Mechanism {
|
||||||
|
|
|
@ -6,9 +6,9 @@ use openssl::pkey::PKey;
|
||||||
use openssl::rand::rand_bytes;
|
use openssl::rand::rand_bytes;
|
||||||
use openssl::error::ErrorStack;
|
use openssl::error::ErrorStack;
|
||||||
|
|
||||||
use common::Password;
|
use crate::common::Password;
|
||||||
|
|
||||||
use secret;
|
use crate::secret;
|
||||||
|
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
|
|
|
@ -163,11 +163,6 @@
|
||||||
//! sasl = "*"
|
//! sasl = "*"
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
extern crate base64;
|
|
||||||
|
|
||||||
#[cfg(feature = "scram")]
|
|
||||||
extern crate openssl;
|
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
|
@ -175,4 +170,4 @@ pub mod client;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub mod secret;
|
pub mod secret;
|
||||||
|
|
||||||
pub use error::Error;
|
pub use crate::error::Error;
|
||||||
|
|
|
@ -21,8 +21,8 @@ pub struct Pbkdf2Sha1 {
|
||||||
impl Pbkdf2Sha1 {
|
impl Pbkdf2Sha1 {
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha1, String> {
|
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha1, String> {
|
||||||
use common::scram::{ScramProvider, Sha1};
|
use crate::common::scram::{ScramProvider, Sha1};
|
||||||
use common::Password;
|
use crate::common::Password;
|
||||||
let digest = Sha1::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
|
let digest = Sha1::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
|
||||||
Ok(Pbkdf2Sha1 {
|
Ok(Pbkdf2Sha1 {
|
||||||
salt: salt.to_vec(),
|
salt: salt.to_vec(),
|
||||||
|
@ -50,8 +50,8 @@ pub struct Pbkdf2Sha256 {
|
||||||
impl Pbkdf2Sha256 {
|
impl Pbkdf2Sha256 {
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha256, String> {
|
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha256, String> {
|
||||||
use common::scram::{ScramProvider, Sha256};
|
use crate::common::scram::{ScramProvider, Sha256};
|
||||||
use common::Password;
|
use crate::common::Password;
|
||||||
let digest = Sha256::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
|
let digest = Sha256::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
|
||||||
Ok(Pbkdf2Sha256 {
|
Ok(Pbkdf2Sha256 {
|
||||||
salt: salt.to_vec(),
|
salt: salt.to_vec(),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use server::{Validator, Response, Mechanism};
|
use crate::server::{Validator, Response, Mechanism};
|
||||||
use common::Identity;
|
use crate::common::Identity;
|
||||||
use secret;
|
use crate::secret;
|
||||||
|
|
||||||
pub struct Plain<V: Validator<secret::Plain>> {
|
pub struct Plain<V: Validator<secret::Plain>> {
|
||||||
validator: V,
|
validator: V,
|
||||||
|
|
|
@ -2,11 +2,11 @@ use std::marker::PhantomData;
|
||||||
|
|
||||||
use base64;
|
use base64;
|
||||||
|
|
||||||
use server::{Provider, Response, Mechanism};
|
use crate::server::{Provider, Response, Mechanism};
|
||||||
use common::{Identity, ChannelBinding, parse_frame, xor};
|
use crate::common::{Identity, ChannelBinding, parse_frame, xor};
|
||||||
use common::scram::{ScramProvider, generate_nonce};
|
use crate::common::scram::{ScramProvider, generate_nonce};
|
||||||
use secret;
|
use crate::secret;
|
||||||
use secret::Pbkdf2Secret;
|
use crate::secret::Pbkdf2Secret;
|
||||||
|
|
||||||
enum ScramState {
|
enum ScramState {
|
||||||
Init,
|
Init,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use common::Identity;
|
use crate::common::Identity;
|
||||||
use secret::Secret;
|
use crate::secret::Secret;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! impl_validator_using_provider {
|
macro_rules! impl_validator_using_provider {
|
||||||
|
|
Loading…
Reference in a new issue