Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #38 from mdavids/master
Browse files Browse the repository at this point in the history
Dependency upgrade
  • Loading branch information
wbl authored Nov 26, 2019
2 parents ad21358 + fae84d6 commit 1815827
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ lazy_static = "1.3.0"
libc = "0.2.49"
log = "0.4.6"
memcache = "0.12.1"
mio = "0.6.16"
mio = "0.6.19"
miscreant = "0.4.2"
net2 = "0.2.33"
nix = "0.13.0"
prometheus = "0.5.0"
rand = "0.6.5"
ring = "0.14.6"
rustls = "0.15.1"
ring = "0.16.9"
rustls = "0.16.0"
simple_logger = "1.0.1"

# More advanced logging system than `log`.
Expand All @@ -48,5 +48,5 @@ slog-stdlog = "~3.0.2"
# please make sure that `TerminalLoggerBuilder::build` doesn't return an error.
sloggers = "=0.3.2"

webpki = "0.19.1"
webpki-roots = "0.16.0"
webpki = "0.21.0"
webpki-roots = "0.18.0"
9 changes: 4 additions & 5 deletions src/key_rotator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use memcache::MemcacheError;

use prometheus::{opts, register_counter, register_int_counter, IntCounter};

use ring::digest;
use ring::hmac;

use std::collections::HashMap;
Expand Down Expand Up @@ -109,7 +108,7 @@ pub struct KeyRotator {
latest_key_id: KeyId,

/// Cache store.
cache: HashMap<KeyId, hmac::Signature>,
cache: HashMap<KeyId, hmac::Tag>,

/// Logger.
// TODO: since we don't use the logger now, I will put an `allow(dead_code)` here first. I will
Expand Down Expand Up @@ -241,7 +240,7 @@ impl KeyRotator {
// It should be private. Don't make it public.
fn cache_insert(&mut self, key_id: KeyId, value: &[u8]) {
// Create a MAC key.
let mac_key = hmac::SigningKey::new(&digest::SHA256, self.master_key.as_bytes());
let mac_key = hmac::Key::new(hmac::HMAC_SHA256, self.master_key.as_bytes());
// Generating a MAC tag with a MAC key.
let tag = hmac::sign(&mac_key, value);

Expand All @@ -255,13 +254,13 @@ impl KeyRotator {
}

/// Return the latest key id and hmac tag of the rotator.
pub fn latest_key_value(&self) -> (KeyId, &hmac::Signature) {
pub fn latest_key_value(&self) -> (KeyId, &hmac::Tag) {
// This unwrap cannot panic because the HashMap will always contain the latest key id.
(self.latest_key_id, self.get(self.latest_key_id).unwrap())
}

/// Return an entry in the cache using a key id.
pub fn get(&self, key_id: KeyId) -> Option<&hmac::Signature> {
pub fn get(&self, key_id: KeyId) -> Option<&hmac::Tag> {
self.cache.get(&key_id)
}
}
Expand Down

0 comments on commit 1815827

Please sign in to comment.