|
47 | 47 |
|
48 | 48 | extern crate bufstream; |
49 | 49 | extern crate byteorder; |
| 50 | +extern crate crypto; |
50 | 51 | #[macro_use] |
51 | 52 | extern crate log; |
52 | | -extern crate openssl; |
53 | 53 | extern crate phf; |
54 | 54 | extern crate rustc_serialize as serialize; |
55 | 55 | #[cfg(feature = "unix_socket")] |
56 | 56 | extern crate unix_socket; |
57 | 57 | extern crate debug_builders; |
58 | 58 |
|
59 | 59 | use bufstream::BufStream; |
| 60 | +use crypto::digest::Digest; |
| 61 | +use crypto::md5::Md5; |
60 | 62 | use debug_builders::DebugStruct; |
61 | | -use openssl::crypto::hash::{self, Hasher}; |
62 | | -use serialize::hex::ToHex; |
63 | 63 | use std::ascii::AsciiExt; |
64 | 64 | use std::borrow::{ToOwned, Cow}; |
65 | 65 | use std::cell::{Cell, RefCell}; |
@@ -640,13 +640,14 @@ impl InnerConnection { |
640 | 640 | } |
641 | 641 | AuthenticationMD5Password { salt } => { |
642 | 642 | let pass = try!(user.password.ok_or(ConnectError::MissingPassword)); |
643 | | - let mut hasher = Hasher::new(hash::Type::MD5); |
644 | | - let _ = hasher.write_all(pass.as_bytes()); |
645 | | - let _ = hasher.write_all(user.user.as_bytes()); |
646 | | - let output = hasher.finish().to_hex(); |
647 | | - let _ = hasher.write_all(output.as_bytes()); |
648 | | - let _ = hasher.write_all(&salt); |
649 | | - let output = format!("md5{}", hasher.finish().to_hex()); |
| 643 | + let mut hasher = Md5::new(); |
| 644 | + let _ = hasher.input(pass.as_bytes()); |
| 645 | + let _ = hasher.input(user.user.as_bytes()); |
| 646 | + let output = hasher.result_str(); |
| 647 | + hasher.reset(); |
| 648 | + let _ = hasher.input(output.as_bytes()); |
| 649 | + let _ = hasher.input(&salt); |
| 650 | + let output = format!("md5{}", hasher.result_str()); |
650 | 651 | try!(self.write_messages(&[PasswordMessage { |
651 | 652 | password: &output |
652 | 653 | }])); |
|
0 commit comments