Use *ring* 0.12.1's Eq implementation for digest::Algorithm.

This commit is contained in:
Brian Smith 2017-09-03 14:44:07 -10:00
parent 3e6204df34
commit d464f7d9dd
2 changed files with 2 additions and 11 deletions

View File

@ -13,7 +13,7 @@ categories = ["network-programming", "cryptography"]
untrusted = "0.5.1"
base64 = "0.6"
log = { version = "0.3.6", optional = true }
ring = { version = "0.12", features = ["rsa_signing"] }
ring = { version = "0.12.1", features = ["rsa_signing"] }
webpki = { git = "https://github.com/briansmith/webpki" }
sct = "0.2"

View File

@ -24,15 +24,6 @@ pub struct HandshakeHash {
buffer: Vec<u8>,
}
// This hack is needed because rust doesn't provide reference
// equality: in other words given a and b of type &T, are
// the references for the same object?
fn hash_eq(ha: &'static digest::Algorithm, hb: &'static digest::Algorithm) -> bool {
let a = digest::digest(ha, &[]);
let b = digest::digest(hb, &[]);
a.as_ref() == b.as_ref()
}
impl HandshakeHash {
pub fn new() -> HandshakeHash {
HandshakeHash {
@ -62,7 +53,7 @@ impl HandshakeHash {
match self.alg {
None => {},
Some(started) => {
if !hash_eq(started, alg) {
if started != alg {
// hash type is changing
warn!("altered hash to HandshakeHash::start_hash");
return false;