From 61d38fb6d976b68191e96657aed85da38cdb9c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolphe=20Br=C3=A9ard?= Date: Sat, 9 Mar 2024 16:09:34 +0100 Subject: [PATCH] Rename the get_value method to get_ctx_elems --- src/encryption.rs | 3 ++- src/kdf.rs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/encryption.rs b/src/encryption.rs index e7e64ca..6a4b4a7 100644 --- a/src/encryption.rs +++ b/src/encryption.rs @@ -19,7 +19,8 @@ fn generate_aad( data_context: &[impl AsRef<[u8]>], time_period: Option, ) -> 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); join_canonicalized_str(&key_context_canon, &data_context_canon) } diff --git a/src/kdf.rs b/src/kdf.rs index 72a0b04..6b7d379 100644 --- a/src/kdf.rs +++ b/src/kdf.rs @@ -17,7 +17,7 @@ impl KeyContext { self.periodicity = Some(periodicity); } - pub(crate) fn get_value(&self, time_period: Option) -> Vec> { + pub(crate) fn get_ctx_elems(&self, time_period: Option) -> Vec> { let mut ret: Vec> = self.ctx.iter().map(|s| s.as_bytes().to_vec()).collect(); if let Some(tp) = time_period { ret.push(tp.to_le_bytes().to_vec()); @@ -48,7 +48,8 @@ pub(crate) fn derive_key( ctx: &KeyContext, time_period: Option, ) -> Vec { - 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(); kdf(&key_context, &ikm.content) }