Skip to content

Commit

Permalink
return err if no cipher version (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx authored Jul 18, 2024
1 parent 11a51ca commit 2de056e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 11 additions & 4 deletions xmtp_mls/src/storage/encrypted_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,22 @@ impl EncryptedMessageStore {

if self.enc_key.is_some() {
let cipher_version = sql_query("PRAGMA cipher_version").load::<CipherVersion>(conn)?;
if cipher_version.is_empty() {
return Err(StorageError::SqlCipherNotLoaded);
}
let cipher_provider_version =
sql_query("PRAGMA cipher_provider_version").load::<CipherProviderVersion>(conn)?;
log::info!(
"Sqlite cipher_version={}, cipher_provider_version={}",
cipher_version[0].cipher_version,
cipher_provider_version[0].cipher_provider_version,
"Sqlite cipher_version={:?}, cipher_provider_version={:?}",
cipher_version.first().as_ref().map(|v| &v.cipher_version),
cipher_provider_version
.first()
.as_ref()
.map(|v| &v.cipher_provider_version)
);
if log_enabled!(log::Level::Info) {
conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;")?;
conn.batch_execute("PRAGMA cipher_log = stderr; PRAGMA cipher_log_level = INFO;")
.ok();
}
}

Expand Down
2 changes: 2 additions & 0 deletions xmtp_mls/src/storage/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub enum StorageError {
Conflict(String),
#[error(transparent)]
Intent(#[from] IntentError),
#[error("The SQLCipher Sqlite extension is not present, but an encryption key is given")]
SqlCipherNotLoaded,
}

impl<T> From<PoisonError<T>> for StorageError {
Expand Down

0 comments on commit 2de056e

Please sign in to comment.