Update to Edition 2018.

This commit is contained in:
Emmanuel Gil Peyrot 2019-01-17 22:54:32 +01:00
parent b1708823de
commit 9e9f09a9a5
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::{Credentials, Secret};
use crate::client::Mechanism;
use crate::common::{Credentials, Secret};
/// 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::{Credentials, Identity, Password, Secret};
use crate::client::Mechanism;
use crate::common::{Credentials, Identity, Password, Secret};
/// A struct for the SASL PLAIN mechanism.
pub struct Plain {

View file

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

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::sign::Signer;
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;
@ -176,4 +171,4 @@ pub mod server;
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(),
@ -56,8 +56,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 common::Identity;
use secret;
use server::{Mechanism, Response, Validator};
use crate::common::Identity;
use crate::secret;
use crate::server::{Mechanism, Response, Validator};
pub struct Plain<V: Validator<secret::Plain>> {
validator: V,

View file

@ -2,11 +2,11 @@ use std::marker::PhantomData;
use base64;
use common::scram::{generate_nonce, ScramProvider};
use common::{parse_frame, xor, ChannelBinding, Identity};
use secret;
use secret::Pbkdf2Secret;
use server::{Mechanism, Provider, Response};
use crate::common::scram::{generate_nonce, ScramProvider};
use crate::common::{parse_frame, xor, ChannelBinding, Identity};
use crate::secret;
use crate::secret::Pbkdf2Secret;
use crate::server::{Mechanism, Provider, Response};
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 {