Skip to content

Commit ba3cad6

Browse files
committed
docs: Mark db encryption support as deprecated (#7403)
- Db encryption does nothing with blobs, so fs/disk encryption is recommended. - Isolation from other apps is needed anyway. - Experimental database encryption was removed on iOS and Android. - Delta Touch is using CFFI API with a manually entered password because Ubuntu Touch does not offer filesystem or disk encryption, but we don't want new users of these APIs, such as bot developers.
1 parent c9c362d commit ba3cad6

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

deltachat-ffi/deltachat.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ typedef struct _dc_event_emitter dc_accounts_event_emitter_t;
247247
// create/open/config/information
248248

249249
/**
250-
* Create a new context object and try to open it without passphrase. If
250+
* Create a new context object and try to open it. If
251251
* database is encrypted, the result is the same as using
252252
* dc_context_new_closed() and the database should be opened with
253253
* dc_context_open() before using.
@@ -283,8 +283,13 @@ dc_context_t* dc_context_new_closed (const char* dbfile);
283283

284284

285285
/**
286-
* Opens the database with the given passphrase. This can only be used on
287-
* closed context, such as created by dc_context_new_closed(). If the database
286+
* Opens the database with the given passphrase.
287+
* NB: Nonempty passphrase (db encryption) is deprecated 2025-11:
288+
* - Db encryption does nothing with blobs, so fs/disk encryption is recommended.
289+
* - Isolation from other apps is needed anyway.
290+
*
291+
* This can only be used on closed context, such as
292+
* created by dc_context_new_closed(). If the database
288293
* is new, this operation sets the database passphrase. For existing databases
289294
* the passphrase should be the one used to encrypt the database the first
290295
* time.
@@ -301,6 +306,8 @@ int dc_context_open (dc_context_t *context, const char*
301306

302307
/**
303308
* Changes the passphrase on the open database.
309+
* Deprecated 2025-11, see `dc_context_open()` for reasoning.
310+
*
304311
* Existing database must already be encrypted and the passphrase cannot be NULL or empty.
305312
* It is impossible to encrypt unencrypted database with this method and vice versa.
306313
*

src/context.rs

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::{chatlist_events, stats};
4646
///
4747
/// # Examples
4848
///
49-
/// Creating a new unencrypted database:
49+
/// Creating a new database:
5050
///
5151
/// ```
5252
/// # let rt = tokio::runtime::Runtime::new().unwrap();
@@ -61,24 +61,6 @@ use crate::{chatlist_events, stats};
6161
/// drop(context);
6262
/// # });
6363
/// ```
64-
///
65-
/// To use an encrypted database provide a password. If the database does not yet exist it
66-
/// will be created:
67-
///
68-
/// ```
69-
/// # let rt = tokio::runtime::Runtime::new().unwrap();
70-
/// # rt.block_on(async move {
71-
/// use deltachat::context::ContextBuilder;
72-
///
73-
/// let dir = tempfile::tempdir().unwrap();
74-
/// let context = ContextBuilder::new(dir.path().join("db"))
75-
/// .with_password("secret".into())
76-
/// .open()
77-
/// .await
78-
/// .unwrap();
79-
/// drop(context);
80-
/// # });
81-
/// ```
8264
#[derive(Clone, Debug)]
8365
pub struct ContextBuilder {
8466
dbfile: PathBuf,
@@ -150,9 +132,13 @@ impl ContextBuilder {
150132
}
151133

152134
/// Sets the password to unlock the database.
135+
/// Deprecated 2025-11:
136+
/// - Db encryption does nothing with blobs, so fs/disk encryption is recommended.
137+
/// - Isolation from other apps is needed anyway.
153138
///
154139
/// If an encrypted database is used it must be opened with a password. Setting a
155140
/// password on a new database will enable encryption.
141+
#[deprecated(since = "TBD")]
156142
pub fn with_password(mut self, password: String) -> Self {
157143
self.password = Some(password);
158144
self
@@ -180,7 +166,7 @@ impl ContextBuilder {
180166

181167
/// Builds the [`Context`] and opens it.
182168
///
183-
/// Returns error if context cannot be opened with the given passphrase.
169+
/// Returns error if context cannot be opened.
184170
pub async fn open(self) -> Result<Context> {
185171
let password = self.password.clone().unwrap_or_default();
186172
let context = self.build().await?;
@@ -400,9 +386,12 @@ impl Context {
400386
}
401387

402388
/// Opens the database with the given passphrase.
389+
/// NB: Db encryption is deprecated, so `passphrase` should be empty normally. See
390+
/// [`ContextBuilder::with_password()`] for reasoning.
403391
///
404392
/// Returns true if passphrase is correct, false is passphrase is not correct. Fails on other
405393
/// errors.
394+
#[deprecated(since = "TBD")]
406395
pub async fn open(&self, passphrase: String) -> Result<bool> {
407396
if self.sql.check_passphrase(passphrase.clone()).await? {
408397
self.sql.open(self, passphrase).await?;
@@ -413,6 +402,7 @@ impl Context {
413402
}
414403

415404
/// Changes encrypted database passphrase.
405+
/// Deprecated 2025-11, see [`ContextBuilder::with_password()`] for reasoning.
416406
pub async fn change_passphrase(&self, passphrase: String) -> Result<()> {
417407
self.sql.change_passphrase(passphrase).await?;
418408
Ok(())

0 commit comments

Comments
 (0)