Prevent setting of encryption keys if already set

This commit is contained in:
Gaurav Sarma
2025-09-06 22:37:12 +08:00
parent efc105d99e
commit b3242a18d9
2 changed files with 9 additions and 0 deletions

View File

@@ -2065,6 +2065,11 @@ impl Connection {
};
tracing::trace!("setting encryption ctx for connection");
let pager = self.pager.borrow();
if pager.is_encryption_ctx_set() {
return Err(LimboError::InvalidArgument(
"cannot reset encryption attributes if already set in the session".to_string(),
));
}
pager.set_encryption_context(cipher_mode, key)
}
}

View File

@@ -2165,6 +2165,10 @@ impl Pager {
Ok(IOResult::Done(f(header)))
}
pub fn is_encryption_ctx_set(&self) -> bool {
self.io_ctx.borrow_mut().encryption_context().is_some()
}
pub fn set_encryption_context(
&self,
cipher_mode: CipherMode,