Skip to content

Commit

Permalink
use less alloc in hkdf
Browse files Browse the repository at this point in the history
  • Loading branch information
zh-jq committed Sep 17, 2024
1 parent 4a55bd9 commit a312801
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion lib/g3-dpi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fnv.workspace = true
bytes.workspace = true
memchr.workspace = true
fixedbitset.workspace = true
smallvec = { workspace = true, optional = true }
openssl = { workspace = true, optional = true }
g3-types = { workspace = true, features = ["http"] }

Expand All @@ -20,4 +21,4 @@ hex-literal.workspace = true

[features]
default = []
quic = ["dep:openssl"]
quic = ["dep:openssl", "dep:smallvec"]
5 changes: 3 additions & 2 deletions lib/g3-dpi/src/parser/quic/packet/hkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ use openssl::error::ErrorStack;
use openssl::md::Md;
use openssl::pkey::Id;
use openssl::pkey_ctx::{HkdfMode, PkeyCtx};
use smallvec::SmallVec;

fn build_info_from_label(label: &[u8], output_len: u16) -> Vec<u8> {
fn build_info_from_label(label: &[u8], output_len: u16) -> SmallVec<[u8; 32]> {
let label_len = 6 + label.len() as u8;
let mut info = Vec::with_capacity(2 + 1 + label_len as usize + 1);
let mut info: SmallVec<[u8; 32]> = SmallVec::with_capacity(2 + 1 + label_len as usize + 1);
let l_bytes = output_len.to_be_bytes();
info.extend_from_slice(&l_bytes);
info.push(label_len);
Expand Down

0 comments on commit a312801

Please sign in to comment.