Skip to content

Commit

Permalink
libsql-ffi: Switch to SQLCipher as the default cipher
Browse files Browse the repository at this point in the history
Fixes #893
  • Loading branch information
penberg committed Feb 19, 2024
1 parent deb17db commit 44eee38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libsql-ffi/bundled/SQLite3MultipleCiphers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ set(SQLITE3MC_BASE_DEFINITIONS
HAVE_CIPHER_AES_128_CBC=0
HAVE_CIPHER_AES_256_CBC=1
HAVE_CIPHER_CHACHA20=0
HAVE_CIPHER_SQLCIPHER=0
HAVE_CIPHER_SQLCIPHER=1
HAVE_CIPHER_RC4=0
HAVE_CIPHER_ASCON128=0
# $<$<BOOL:${SQLITE_USE_TCL}>:SQLITE_USE_TCL=1>
Expand Down
6 changes: 5 additions & 1 deletion libsql-sys/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ type Error = crate::Error;

#[derive(Clone, Debug)]
pub enum Cipher {
// SQLCipher: AES 256 Bit (recommended)
SQLCipher,
// AES 256 Bit CBC - No HMAC (wxSQLite3)
Aes256Cbc,
}

impl Default for Cipher {
fn default() -> Self {
Cipher::Aes256Cbc
Cipher::SQLCipher
}
}

Expand All @@ -36,6 +38,7 @@ impl FromStr for Cipher {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"sqlcipher" => Ok(Cipher::SQLCipher),
"aes256cbc" => Ok(Cipher::Aes256Cbc),
_ => Err(format!("{} is not a supported cipher for encryption", s)),
}
Expand All @@ -46,6 +49,7 @@ impl Cipher {
#[cfg(feature = "encryption")]
pub fn cipher_id(&self) -> i32 {
let name = match self {
Cipher::SQLCipher => "sqlcipher\0",
Cipher::Aes256Cbc => "aes256cbc\0",
};
unsafe { sqlite3mc_cipher_index(name.as_ptr() as _) }
Expand Down

0 comments on commit 44eee38

Please sign in to comment.