Use a NonZeroU64 since the periodicity cannot be zero

This commit is contained in:
Rodolphe Bréard 2024-03-09 16:26:21 +01:00
parent 61d38fb6d9
commit cac466f5ed

View file

@ -1,5 +1,6 @@
use crate::canonicalization::canonicalize; use crate::canonicalization::canonicalize;
use crate::ikm::InputKeyMaterial; use crate::ikm::InputKeyMaterial;
use std::num::NonZeroU64;
pub(crate) type KdfFunction = dyn Fn(&str, &[u8]) -> Vec<u8>; pub(crate) type KdfFunction = dyn Fn(&str, &[u8]) -> Vec<u8>;
@ -13,8 +14,8 @@ impl KeyContext {
self.periodicity = None; self.periodicity = None;
} }
pub fn set_periodicity(&mut self, periodicity: u64) { pub fn set_periodicity(&mut self, periodicity: NonZeroU64) {
self.periodicity = Some(periodicity); self.periodicity = Some(periodicity.get());
} }
pub(crate) fn get_ctx_elems(&self, time_period: Option<u64>) -> Vec<Vec<u8>> { pub(crate) fn get_ctx_elems(&self, time_period: Option<u64>) -> Vec<Vec<u8>> {