Skip to content

Commit 6ecfa10

Browse files
committed
drop ring
1 parent b525379 commit 6ecfa10

File tree

3 files changed

+13
-35
lines changed

3 files changed

+13
-35
lines changed

Cargo.lock

Lines changed: 2 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ http = "0.2"
2626
rmp-serde = "1.1"
2727
brotli = "3.3.3"
2828
semver = "1.0"
29-
ring = "0.16.10"
29+
hmac = "0.12"
30+
sha1 = "0.10"
3031
hex = "0.4.2"
3132
regex = "1"
3233
toml = "0.7"

site/src/server.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use brotli::enc::BrotliEncoderParams;
22
use brotli::BrotliCompress;
3+
use hmac::{Hmac, Mac};
34
use std::collections::HashMap;
45
use std::net::SocketAddr;
56
use std::path::Path;
@@ -15,9 +16,9 @@ use http::header::CACHE_CONTROL;
1516
use hyper::StatusCode;
1617
use log::{debug, error, info};
1718
use parking_lot::{Mutex, RwLock};
18-
use ring::hmac;
1919
use serde::de::DeserializeOwned;
2020
use serde::Serialize;
21+
use sha1::Sha1;
2122
use uuid::Uuid;
2223

2324
pub use crate::api::{
@@ -699,13 +700,15 @@ fn verify_gh(config: &Config, req: &http::request::Parts, body: &[u8]) -> bool {
699700
}
700701

701702
fn verify_gh_sig(cfg: &Config, header: &str, body: &[u8]) -> Option<bool> {
702-
let key = hmac::Key::new(
703-
hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY,
704-
cfg.keys.github_webhook_secret.as_ref().unwrap().as_bytes(),
705-
);
703+
type HmacSha1 = Hmac<Sha1>;
704+
705+
let mut mac =
706+
HmacSha1::new_from_slice(cfg.keys.github_webhook_secret.as_ref().unwrap().as_bytes())
707+
.expect("HMAC can take key of any size");
708+
mac.update(body);
706709
let sha = header.get(5..)?; // strip sha1=
707710
let sha = hex::decode(sha).ok()?;
708-
if let Ok(()) = hmac::verify(&key, body, &sha) {
711+
if let Ok(()) = mac.verify_slice(&sha) {
709712
return Some(true);
710713
}
711714

0 commit comments

Comments
 (0)