Skip to content

Commit

Permalink
Rename const HKDF_INFO_DEFAULT_CAPACITY_LEN
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed May 22, 2024
1 parent aa940f7 commit fed7282
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aws-lc-rs/src/hkdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ pub static HKDF_SHA512: Algorithm = Algorithm(hmac::HMAC_SHA512);
const MAX_HKDF_SALT_LEN: usize = 80;

/// General Info length's for HKDF don't normally exceed 256 bits.
/// We set the limit to something tolerable, so that the memory passed into |`HKDF_expand`| is
/// allocated on the stack.
const MAX_HKDF_INFO_STACK_LEN: usize = 102;
/// We set the default capacity to a value larger than should be needed
/// so that the value passed to |`HKDF_expand`| is only allocated once.
const HKDF_INFO_DEFAULT_CAPACITY_LEN: usize = 300;

/// The maximum output size of a PRK computed by |`HKDF_extract`| is the maximum digest
/// size that can be outputted by *AWS-LC*.
Expand Down Expand Up @@ -360,7 +360,7 @@ impl Prk {
if len_cached > 255 * self.algorithm.0.digest_algorithm().output_len {
return Err(Unspecified);
}
let mut info_bytes: Vec<u8> = Vec::with_capacity(3 * MAX_HKDF_INFO_STACK_LEN);
let mut info_bytes: Vec<u8> = Vec::with_capacity(HKDF_INFO_DEFAULT_CAPACITY_LEN);
let mut info_len = 0;
for &byte_ary in info {
info_bytes.extend_from_slice(byte_ary);
Expand Down

0 comments on commit fed7282

Please sign in to comment.