mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-23 18:04:27 +01:00
Prevent setting of encryption keys if already set
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user