diff --git a/Cargo.toml b/Cargo.toml index 329f2ae..7ae94ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,8 @@ email = "^0.0" log = "^0.3" mime = "^0.2" openssl = "^0.9" +base64 = "~0.5.0" +hex = "^0.2.0" rustc-serialize = "^0.3" rust-crypto = "^0.2" time = "^0.1" diff --git a/src/lib.rs b/src/lib.rs index f9524b0..da66823 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -276,7 +276,8 @@ extern crate log; #[macro_use] extern crate mime; -extern crate rustc_serialize; +extern crate base64; +extern crate hex; extern crate crypto; extern crate time; extern crate uuid; diff --git a/src/transport/smtp/authentication.rs b/src/transport/smtp/authentication.rs index e7ac401..47ddcd0 100644 --- a/src/transport/smtp/authentication.rs +++ b/src/transport/smtp/authentication.rs @@ -3,7 +3,7 @@ use crypto::hmac::Hmac; use crypto::mac::Mac; use crypto::md5::Md5; -use rustc_serialize::hex::ToHex; +use hex::ToHex; use std::fmt; use std::fmt::{Display, Formatter}; use transport::smtp::NUL; diff --git a/src/transport/smtp/client/mod.rs b/src/transport/smtp/client/mod.rs index 69c98a2..0c62b4b 100644 --- a/src/transport/smtp/client/mod.rs +++ b/src/transport/smtp/client/mod.rs @@ -3,7 +3,7 @@ use bufstream::BufStream; use openssl::ssl::SslContext; -use rustc_serialize::base64::{self, FromBase64, ToBase64}; +use base64; use std::fmt::Debug; use std::io; use std::io::{BufRead, Read, Write}; @@ -204,9 +204,7 @@ impl Client { if mechanism.supports_initial_response() { self.command(&format!("AUTH {} {}", mechanism, - try!(mechanism.response(username, password, None)) - .as_bytes() - .to_base64(base64::STANDARD))) + base64::encode_config(try!(mechanism.response(username, password, None)).as_bytes(), base64::STANDARD))) } else { let encoded_challenge = match try!(self.command(&format!("AUTH {}", mechanism))) .first_word() { @@ -216,7 +214,7 @@ impl Client { debug!("auth encoded challenge: {}", encoded_challenge); - let decoded_challenge = match encoded_challenge.from_base64() { + let decoded_challenge = match base64::decode(&encoded_challenge) { Ok(challenge) => { match String::from_utf8(challenge) { Ok(value) => value, @@ -231,11 +229,10 @@ impl Client { let mut challenge_expected = 3; while challenge_expected > 0 { - let response = try!(self.command(&try!(mechanism.response(username, + let response = try!(self.command(&base64::encode_config(&try!(mechanism.response(username, password, Some(&decoded_challenge))) - .as_bytes() - .to_base64(base64::STANDARD))); + .as_bytes(), base64::STANDARD))); if !response.has_code(334) { return Ok(response); diff --git a/src/transport/smtp/error.rs b/src/transport/smtp/error.rs index 942fb8e..4a0a29e 100644 --- a/src/transport/smtp/error.rs +++ b/src/transport/smtp/error.rs @@ -1,7 +1,7 @@ //! Error and result type for SMTP clients use self::Error::*; -use rustc_serialize::base64::FromBase64Error; +use base64::DecodeError; use std::error::Error as StdError; use std::fmt; use std::fmt::{Display, Formatter}; @@ -23,7 +23,7 @@ pub enum Error { /// Error parsing a response ResponseParsing(&'static str), /// Error parsing a base64 string in response - ChallengeParsing(FromBase64Error), + ChallengeParsing(DecodeError), /// Error parsing UTF8in response Utf8Parsing(FromUtf8Error), /// Internal client error