Skip to content

Commit 25ba140

Browse files
committed
Use postgres_protocol for md5 hashing
1 parent 42fa212 commit 25ba140

File tree

3 files changed

+2
-596
lines changed

3 files changed

+2
-596
lines changed

THIRD_PARTY

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,3 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
5757
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
5858
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
5959
DEALINGS IN THE SOFTWARE.
60-
61-
-------------------------------------------------------------------------------
62-
63-
* src/md5.rs has been copied from rust-crypto
64-
65-
Copyright (c) 2006-2009 Graydon Hoare
66-
Copyright (c) 2009-2013 Mozilla Foundation
67-
68-
Permission is hereby granted, free of charge, to any
69-
person obtaining a copy of this software and associated
70-
documentation files (the "Software"), to deal in the
71-
Software without restriction, including without
72-
limitation the rights to use, copy, modify, merge,
73-
publish, distribute, sublicense, and/or sell copies of
74-
the Software, and to permit persons to whom the Software
75-
is furnished to do so, subject to the following
76-
conditions:
77-
78-
The above copyright notice and this permission notice
79-
shall be included in all copies or substantial portions
80-
of the Software.
81-
82-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
83-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
84-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
85-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
86-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
87-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
88-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
89-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
90-
DEALINGS IN THE SOFTWARE.

src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ extern crate log;
5151
extern crate phf;
5252
extern crate postgres_protocol;
5353

54-
use md5::Md5;
5554
use std::cell::{Cell, RefCell};
5655
use std::collections::{VecDeque, HashMap};
5756
use std::fmt;
@@ -61,6 +60,7 @@ use std::mem;
6160
use std::result;
6261
use std::sync::Arc;
6362
use std::time::Duration;
63+
use postgres_protocol::authentication;
6464
use postgres_protocol::message::backend::{self, RowDescriptionEntry};
6565
use postgres_protocol::message::frontend;
6666

@@ -78,7 +78,6 @@ use types::{IsNull, Kind, Type, SessionInfo, Oid, Other, WrongType, ToSql, FromS
7878
mod macros;
7979

8080
mod feature_check;
81-
mod md5;
8281
mod priv_io;
8382
mod url;
8483
pub mod error;
@@ -382,14 +381,7 @@ impl InnerConnection {
382381
let pass = try!(user.password.ok_or_else(|| {
383382
ConnectError::ConnectParams("a password was requested but not provided".into())
384383
}));
385-
let mut hasher = Md5::new();
386-
hasher.input(pass.as_bytes());
387-
hasher.input(user.user.as_bytes());
388-
let output = hasher.result_str();
389-
hasher.reset();
390-
hasher.input(output.as_bytes());
391-
hasher.input(&salt);
392-
let output = format!("md5{}", hasher.result_str());
384+
let output = authentication::md5_hash(user.user.as_bytes(), pass.as_bytes(), salt);
393385
try!(self.stream.write_message(&frontend::PasswordMessage { password: &output }));
394386
try!(self.stream.flush());
395387
}

0 commit comments

Comments
 (0)