Rename the get_value method to get_ctx_elems
This commit is contained in:
parent
35400b7278
commit
61d38fb6d9
2 changed files with 5 additions and 3 deletions
|
@ -19,7 +19,8 @@ fn generate_aad(
|
||||||
data_context: &[impl AsRef<[u8]>],
|
data_context: &[impl AsRef<[u8]>],
|
||||||
time_period: Option<u64>,
|
time_period: Option<u64>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let key_context_canon = canonicalize(&key_context.get_value(time_period));
|
let elems = key_context.get_ctx_elems(time_period);
|
||||||
|
let key_context_canon = canonicalize(&elems);
|
||||||
let data_context_canon = canonicalize(data_context);
|
let data_context_canon = canonicalize(data_context);
|
||||||
join_canonicalized_str(&key_context_canon, &data_context_canon)
|
join_canonicalized_str(&key_context_canon, &data_context_canon)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ impl KeyContext {
|
||||||
self.periodicity = Some(periodicity);
|
self.periodicity = Some(periodicity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_value(&self, time_period: Option<u64>) -> Vec<Vec<u8>> {
|
pub(crate) fn get_ctx_elems(&self, time_period: Option<u64>) -> Vec<Vec<u8>> {
|
||||||
let mut ret: Vec<Vec<u8>> = self.ctx.iter().map(|s| s.as_bytes().to_vec()).collect();
|
let mut ret: Vec<Vec<u8>> = self.ctx.iter().map(|s| s.as_bytes().to_vec()).collect();
|
||||||
if let Some(tp) = time_period {
|
if let Some(tp) = time_period {
|
||||||
ret.push(tp.to_le_bytes().to_vec());
|
ret.push(tp.to_le_bytes().to_vec());
|
||||||
|
@ -48,7 +48,8 @@ pub(crate) fn derive_key(
|
||||||
ctx: &KeyContext,
|
ctx: &KeyContext,
|
||||||
time_period: Option<u64>,
|
time_period: Option<u64>,
|
||||||
) -> Vec<u8> {
|
) -> Vec<u8> {
|
||||||
let key_context = canonicalize(&ctx.get_value(time_period));
|
let elems = ctx.get_ctx_elems(time_period);
|
||||||
|
let key_context = canonicalize(&elems);
|
||||||
let kdf = ikm.scheme.get_kdf();
|
let kdf = ikm.scheme.get_kdf();
|
||||||
kdf(&key_context, &ikm.content)
|
kdf(&key_context, &ikm.content)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue