Fixed critical issue

This commit is contained in:
Hannes 2022-03-23 17:01:39 +01:00
parent 6c406867c3
commit b7e05e5766

View file

@ -111,10 +111,11 @@ impl Ratchet {
return Err("Skipped to many keys"); return Err("Skipped to many keys");
} }
match self.ckr { match self.ckr {
Some(d) => { Some(mut d) => {
while self.nr < until { while self.nr < until {
let (ckr, mk) = kdf_ck(&d); let (ckr, mk) = kdf_ck(&d);
self.ckr = Some(ckr); self.ckr = Some(ckr);
d = ckr;
self.mkskipped.insert((self.dhr.unwrap().to_string().as_bytes().to_vec(), self.nr), mk); self.mkskipped.insert((self.dhr.unwrap().to_string().as_bytes().to_vec(), self.nr), mk);
self.nr += 1 self.nr += 1
} }
@ -372,10 +373,11 @@ impl RatchetEncHeader {
if self.nr + MAX_SKIP < until { if self.nr + MAX_SKIP < until {
return Err("Skipping went wrong") return Err("Skipping went wrong")
} }
if let Some(d) = self.ckr { if let Some(mut d) = self.ckr {
while self.nr < until { while self.nr < until {
let (ckr, mk) = kdf_ck(&d); let (ckr, mk) = kdf_ck(&d);
self.ckr = Some(ckr); self.ckr = Some(ckr);
d = ckr;
self.mkskipped.insert((self.hkr, self.nr), mk); self.mkskipped.insert((self.hkr, self.nr), mk);
self.nr += 1 self.nr += 1
} }