Skip to content

Commit 3bbefc5

Browse files
committed
Merge branch 'master' into 'prod'
v0.1.1-rc.2 See merge request huangjj27/tls_sig_api!9
2 parents d4eb223 + 8aa6852 commit 3bbefc5

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tls_sig_api"
3-
version = "0.1.1-rc.1"
3+
version = "0.1.1-rc.2"
44
authors = ["huangjj27 <huangjj.27@qq.com>"]
55
edition = "2018"
66
license = "MIT"
@@ -19,7 +19,8 @@ gitlab = { repository = "https://gitlab.com/huangjj27/tls_sig_api", branch = "pr
1919

2020
[dependencies]
2121
base64 = "0.10"
22-
ring = "0.16"
22+
hmac = "0.7"
23+
sha2 = "0.8"
2324
serde_json = { version = "1.0", features = ["preserve_order"] }
2425
deflate = "0.8"
2526
chrono = "0.4"

src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use chrono::{DateTime, Duration, Utc};
22
use deflate::{deflate_bytes_zlib_conf, Compression};
33
use log::*;
4-
use ring::hmac;
4+
use sha2::Sha256;
5+
use hmac::{Hmac, Mac};
56
use serde_json::json;
67

78
pub struct TlsSigApiVer2 {
@@ -108,8 +109,10 @@ impl TlsSigApiVer2 {
108109

109110
debug!("raw_content_to_be_signed: {}", raw_content_to_be_signed);
110111

111-
let key = hmac::Key::new(hmac::HMAC_SHA256, self.secret.as_bytes());
112-
let digest = hmac::sign(&key, raw_content_to_be_signed.as_bytes());
112+
let mut mac = Hmac::<Sha256>::new_varkey(self.secret.as_bytes())
113+
.expect("HMAC can take key of any size");
114+
mac.input(raw_content_to_be_signed.as_bytes());
115+
let digest = mac.result().code();
113116

114117
base64::encode_config(digest.as_ref(), base64::STANDARD)
115118
}

0 commit comments

Comments
 (0)