Update to Edition 2018.

This commit is contained in:
Emmanuel Gil Peyrot 2019-01-17 22:54:32 +01:00
parent a0c513f309
commit 03923d4885
11 changed files with 30 additions and 34 deletions

View file

@ -9,6 +9,7 @@ documentation = "https://docs.rs/sasl"
readme = "README.md"
keywords = ["sasl", "authentication"]
license = "LGPL-3.0+"
edition = "2018"
[badges]
gitlab = { repository = "lumi/sasl-rs" }

View file

@ -1,7 +1,7 @@
//! Provides the SASL "ANONYMOUS" mechanism.
use client::Mechanism;
use common::{Secret, Credentials};
use crate::client::Mechanism;
use crate::common::{Secret, Credentials};
/// A struct for the SASL ANONYMOUS mechanism.
pub struct Anonymous;

View file

@ -1,7 +1,7 @@
//! Provides the SASL "PLAIN" mechanism.
use client::Mechanism;
use common::{Secret, Credentials, Password, Identity};
use crate::client::Mechanism;
use crate::common::{Secret, Credentials, Password, Identity};
/// A struct for the SASL PLAIN mechanism.
pub struct Plain {

View file

@ -2,11 +2,11 @@
use base64;
use client::Mechanism;
use common::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity};
use common::scram::{ScramProvider, generate_nonce};
use crate::client::Mechanism;
use crate::common::{ChannelBinding, parse_frame, xor, Password, Credentials, Secret, Identity};
use crate::common::scram::{ScramProvider, generate_nonce};
use error::Error;
use crate::error::Error;
use std::marker::PhantomData;
@ -168,9 +168,9 @@ impl<S: ScramProvider> Mechanism for Scram<S> {
#[cfg(test)]
mod tests {
use client::Mechanism;
use client::mechanisms::Scram;
use common::scram::{Sha1, Sha256};
use crate::client::Mechanism;
use crate::client::mechanisms::Scram;
use crate::common::scram::{Sha1, Sha256};
#[test]
fn scram_sha1_works() { // Source: https://wiki.xmpp.org/web/SASLandSCRAM-SHA-1

View file

@ -1,4 +1,4 @@
use common::Credentials;
use crate::common::Credentials;
/// A trait which defines SASL mechanisms.
pub trait Mechanism {

View file

@ -6,9 +6,9 @@ use openssl::pkey::PKey;
use openssl::rand::rand_bytes;
use openssl::error::ErrorStack;
use common::Password;
use crate::common::Password;
use secret;
use crate::secret;
use base64;

View file

@ -163,11 +163,6 @@
//! sasl = "*"
//! ```
extern crate base64;
#[cfg(feature = "scram")]
extern crate openssl;
mod error;
pub mod client;
@ -175,4 +170,4 @@ pub mod client;
pub mod common;
pub mod secret;
pub use error::Error;
pub use crate::error::Error;

View file

@ -21,8 +21,8 @@ pub struct Pbkdf2Sha1 {
impl Pbkdf2Sha1 {
#[cfg(feature = "openssl")]
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha1, String> {
use common::scram::{ScramProvider, Sha1};
use common::Password;
use crate::common::scram::{ScramProvider, Sha1};
use crate::common::Password;
let digest = Sha1::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
Ok(Pbkdf2Sha1 {
salt: salt.to_vec(),
@ -50,8 +50,8 @@ pub struct Pbkdf2Sha256 {
impl Pbkdf2Sha256 {
#[cfg(feature = "openssl")]
pub fn derive(password: &str, salt: &[u8], iterations: usize) -> Result<Pbkdf2Sha256, String> {
use common::scram::{ScramProvider, Sha256};
use common::Password;
use crate::common::scram::{ScramProvider, Sha256};
use crate::common::Password;
let digest = Sha256::derive(&Password::Plain(password.to_owned()), salt, iterations)?;
Ok(Pbkdf2Sha256 {
salt: salt.to_vec(),

View file

@ -1,6 +1,6 @@
use server::{Validator, Response, Mechanism};
use common::Identity;
use secret;
use crate::server::{Validator, Response, Mechanism};
use crate::common::Identity;
use crate::secret;
pub struct Plain<V: Validator<secret::Plain>> {
validator: V,

View file

@ -2,11 +2,11 @@ use std::marker::PhantomData;
use base64;
use server::{Provider, Response, Mechanism};
use common::{Identity, ChannelBinding, parse_frame, xor};
use common::scram::{ScramProvider, generate_nonce};
use secret;
use secret::Pbkdf2Secret;
use crate::server::{Provider, Response, Mechanism};
use crate::common::{Identity, ChannelBinding, parse_frame, xor};
use crate::common::scram::{ScramProvider, generate_nonce};
use crate::secret;
use crate::secret::Pbkdf2Secret;
enum ScramState {
Init,

View file

@ -1,5 +1,5 @@
use common::Identity;
use secret::Secret;
use crate::common::Identity;
use crate::secret::Secret;
#[macro_export]
macro_rules! impl_validator_using_provider {