Skip to content

Commit

Permalink
Use postgres_protocol for md5 hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed Sep 16, 2016
1 parent 42fa212 commit 25ba140
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 596 deletions.
31 changes: 0 additions & 31 deletions THIRD_PARTY
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,3 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

-------------------------------------------------------------------------------

* src/md5.rs has been copied from rust-crypto

Copyright (c) 2006-2009 Graydon Hoare
Copyright (c) 2009-2013 Mozilla Foundation

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
12 changes: 2 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ extern crate log;
extern crate phf;
extern crate postgres_protocol;

use md5::Md5;
use std::cell::{Cell, RefCell};
use std::collections::{VecDeque, HashMap};
use std::fmt;
Expand All @@ -61,6 +60,7 @@ use std::mem;
use std::result;
use std::sync::Arc;
use std::time::Duration;
use postgres_protocol::authentication;
use postgres_protocol::message::backend::{self, RowDescriptionEntry};
use postgres_protocol::message::frontend;

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

mod feature_check;
mod md5;
mod priv_io;
mod url;
pub mod error;
Expand Down Expand Up @@ -382,14 +381,7 @@ impl InnerConnection {
let pass = try!(user.password.ok_or_else(|| {
ConnectError::ConnectParams("a password was requested but not provided".into())
}));
let mut hasher = Md5::new();
hasher.input(pass.as_bytes());
hasher.input(user.user.as_bytes());
let output = hasher.result_str();
hasher.reset();
hasher.input(output.as_bytes());
hasher.input(&salt);
let output = format!("md5{}", hasher.result_str());
let output = authentication::md5_hash(user.user.as_bytes(), pass.as_bytes(), salt);
try!(self.stream.write_message(&frontend::PasswordMessage { password: &output }));
try!(self.stream.flush());
}
Expand Down
Loading

0 comments on commit 25ba140

Please sign in to comment.