Skip to content

Commit 47b785f

Browse files
committed
api!: remove functions for sending and receiving Autocrypt Setup Message
1 parent e14151d commit 47b785f

File tree

24 files changed

+21
-927
lines changed

24 files changed

+21
-927
lines changed

deltachat-ffi/deltachat.h

Lines changed: 3 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,76 +2471,6 @@ void dc_imex (dc_context_t* context, int what, c
24712471
char* dc_imex_has_backup (dc_context_t* context, const char* dir);
24722472

24732473

2474-
/**
2475-
* Initiate Autocrypt Setup Transfer.
2476-
* Before starting the setup transfer with this function, the user should be asked:
2477-
*
2478-
* ~~~
2479-
* "An 'Autocrypt Setup Message' securely shares your end-to-end setup with other Autocrypt-compliant apps.
2480-
* The setup will be encrypted by a setup code which is displayed here and must be typed on the other device.
2481-
* ~~~
2482-
*
2483-
* After that, this function should be called to send the Autocrypt Setup Message.
2484-
* The function creates the setup message and adds it to outgoing message queue.
2485-
* The message is sent asynchronously.
2486-
*
2487-
* The required setup code is returned in the following format:
2488-
*
2489-
* ~~~
2490-
* 1234-1234-1234-1234-1234-1234-1234-1234-1234
2491-
* ~~~
2492-
*
2493-
* The setup code should be shown to the user then:
2494-
*
2495-
* ~~~
2496-
* "Your key has been sent to yourself. Switch to the other device and
2497-
* open the setup message. You should be prompted for a setup code. Type
2498-
* the following digits into the prompt:
2499-
*
2500-
* 1234 - 1234 - 1234 -
2501-
* 1234 - 1234 - 1234 -
2502-
* 1234 - 1234 - 1234
2503-
*
2504-
* Once you're done, your other device will be ready to use Autocrypt."
2505-
* ~~~
2506-
*
2507-
* On the _other device_ you will call dc_continue_key_transfer() then
2508-
* for setup messages identified by dc_msg_is_setupmessage().
2509-
*
2510-
* For more details about the Autocrypt setup process, please refer to
2511-
* https://autocrypt.org/en/latest/level1.html#autocrypt-setup-message
2512-
*
2513-
* @memberof dc_context_t
2514-
* @param context The context object.
2515-
* @return The setup code. Must be released using dc_str_unref() after usage.
2516-
* On errors, e.g. if the message could not be sent, NULL is returned.
2517-
*/
2518-
char* dc_initiate_key_transfer (dc_context_t* context);
2519-
2520-
2521-
/**
2522-
* Continue the Autocrypt Key Transfer on another device.
2523-
*
2524-
* If you have started the key transfer on another device using dc_initiate_key_transfer()
2525-
* and you've detected a setup message with dc_msg_is_setupmessage(), you should prompt the
2526-
* user for the setup code and call this function then.
2527-
*
2528-
* You can use dc_msg_get_setupcodebegin() to give the user a hint about the code (useful if the user
2529-
* has created several messages and should not enter the wrong code).
2530-
*
2531-
* @memberof dc_context_t
2532-
* @param context The context object.
2533-
* @param msg_id The ID of the setup message to decrypt.
2534-
* @param setup_code The setup code entered by the user. This is the same setup code as returned from
2535-
* dc_initiate_key_transfer() on the other device.
2536-
* There is no need to format the string correctly, the function will remove all spaces and other characters and
2537-
* insert the `-` characters at the correct places.
2538-
* @return 1=key successfully decrypted and imported; both devices will use the same key now;
2539-
* 0=key transfer failed e.g. due to a bad setup code.
2540-
*/
2541-
int dc_continue_key_transfer (dc_context_t* context, uint32_t msg_id, const char* setup_code);
2542-
2543-
25442474
/**
25452475
* Signal an ongoing process to stop.
25462476
*
@@ -4659,7 +4589,10 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
46594589
#define DC_INFO_GROUP_IMAGE_CHANGED 3
46604590
#define DC_INFO_MEMBER_ADDED_TO_GROUP 4
46614591
#define DC_INFO_MEMBER_REMOVED_FROM_GROUP 5
4592+
4593+
// Deprecated as of 2026-03-16, not used for new messages.
46624594
#define DC_INFO_AUTOCRYPT_SETUP_MESSAGE 6
4595+
46634596
#define DC_INFO_SECURE_JOIN_MESSAGE 7
46644597
#define DC_INFO_LOCATIONSTREAMING_ENABLED 8
46654598
#define DC_INFO_LOCATION_ONLY 9
@@ -4689,40 +4622,6 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
46894622
char* dc_msg_get_webxdc_href (const dc_msg_t* msg);
46904623

46914624

4692-
/**
4693-
* Check if the message is an Autocrypt Setup Message.
4694-
*
4695-
* Setup messages should be shown in an unique way e.g. using a different text color.
4696-
* On a click or another action, the user should be prompted for the setup code
4697-
* which is forwarded to dc_continue_key_transfer() then.
4698-
*
4699-
* Setup message are typically generated by dc_initiate_key_transfer() on another device.
4700-
*
4701-
* @memberof dc_msg_t
4702-
* @param msg The message object.
4703-
* @return 1=message is a setup message, 0=no setup message.
4704-
* For setup messages, dc_msg_get_viewtype() returns #DC_MSG_FILE.
4705-
*/
4706-
int dc_msg_is_setupmessage (const dc_msg_t* msg);
4707-
4708-
4709-
/**
4710-
* Get the first characters of the setup code.
4711-
*
4712-
* Typically, this is used to pre-fill the first entry field of the setup code.
4713-
* If the user has several setup messages, he can be sure typing in the correct digits.
4714-
*
4715-
* To check, if a message is a setup message, use dc_msg_is_setupmessage().
4716-
* To decrypt a secret key from a setup message, use dc_continue_key_transfer().
4717-
*
4718-
* @memberof dc_msg_t
4719-
* @param msg The message object.
4720-
* @return Typically the first two digits of the setup code or an empty string if unknown.
4721-
* NULL is never returned. Must be released using dc_str_unref() when done.
4722-
*/
4723-
char* dc_msg_get_setupcodebegin (const dc_msg_t* msg);
4724-
4725-
47264625
/**
47274626
* Gets the error status of the message.
47284627
* If there is no error associated with the message, NULL is returned.

deltachat-ffi/src/lib.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,45 +2429,6 @@ pub unsafe extern "C" fn dc_imex_has_backup(
24292429
}
24302430
}
24312431

2432-
#[no_mangle]
2433-
pub unsafe extern "C" fn dc_initiate_key_transfer(context: *mut dc_context_t) -> *mut libc::c_char {
2434-
if context.is_null() {
2435-
eprintln!("ignoring careless call to dc_initiate_key_transfer()");
2436-
return ptr::null_mut(); // NULL explicitly defined as "error"
2437-
}
2438-
let ctx = &*context;
2439-
2440-
match block_on(imex::initiate_key_transfer(ctx))
2441-
.context("dc_initiate_key_transfer()")
2442-
.log_err(ctx)
2443-
{
2444-
Ok(res) => res.strdup(),
2445-
Err(_) => ptr::null_mut(),
2446-
}
2447-
}
2448-
2449-
#[no_mangle]
2450-
pub unsafe extern "C" fn dc_continue_key_transfer(
2451-
context: *mut dc_context_t,
2452-
msg_id: u32,
2453-
setup_code: *const libc::c_char,
2454-
) -> libc::c_int {
2455-
if context.is_null() || msg_id <= constants::DC_MSG_ID_LAST_SPECIAL || setup_code.is_null() {
2456-
eprintln!("ignoring careless call to dc_continue_key_transfer()");
2457-
return 0;
2458-
}
2459-
let ctx = &*context;
2460-
2461-
block_on(imex::continue_key_transfer(
2462-
ctx,
2463-
MsgId::new(msg_id),
2464-
&to_string_lossy(setup_code),
2465-
))
2466-
.context("dc_continue_key_transfer")
2467-
.log_err(ctx)
2468-
.is_ok() as libc::c_int
2469-
}
2470-
24712432
#[no_mangle]
24722433
pub unsafe extern "C" fn dc_stop_ongoing_process(context: *mut dc_context_t) {
24732434
if context.is_null() {
@@ -3790,16 +3751,6 @@ pub unsafe extern "C" fn dc_msg_get_webxdc_href(msg: *mut dc_msg_t) -> *mut libc
37903751
ffi_msg.message.get_webxdc_href().strdup()
37913752
}
37923753

3793-
#[no_mangle]
3794-
pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg_t) -> libc::c_int {
3795-
if msg.is_null() {
3796-
eprintln!("ignoring careless call to dc_msg_is_setupmessage()");
3797-
return 0;
3798-
}
3799-
let ffi_msg = &*msg;
3800-
ffi_msg.message.is_setupmessage().into()
3801-
}
3802-
38033754
#[no_mangle]
38043755
pub unsafe extern "C" fn dc_msg_has_html(msg: *mut dc_msg_t) -> libc::c_int {
38053756
if msg.is_null() {
@@ -3810,20 +3761,6 @@ pub unsafe extern "C" fn dc_msg_has_html(msg: *mut dc_msg_t) -> libc::c_int {
38103761
ffi_msg.message.has_html().into()
38113762
}
38123763

3813-
#[no_mangle]
3814-
pub unsafe extern "C" fn dc_msg_get_setupcodebegin(msg: *mut dc_msg_t) -> *mut libc::c_char {
3815-
if msg.is_null() {
3816-
eprintln!("ignoring careless call to dc_msg_get_setupcodebegin()");
3817-
return "".strdup();
3818-
}
3819-
let ffi_msg = &*msg;
3820-
let ctx = &*ffi_msg.context;
3821-
3822-
block_on(ffi_msg.message.get_setupcodebegin(ctx))
3823-
.unwrap_or_default()
3824-
.strdup()
3825-
}
3826-
38273764
#[no_mangle]
38283765
pub unsafe extern "C" fn dc_msg_set_text(msg: *mut dc_msg_t, text: *const libc::c_char) {
38293766
if msg.is_null() {

deltachat-jsonrpc/src/api.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -699,25 +699,6 @@ impl CommandApi {
699699
message::estimate_deletion_cnt(&ctx, from_server, seconds).await
700700
}
701701

702-
// ---------------------------------------------
703-
// autocrypt
704-
// ---------------------------------------------
705-
706-
async fn initiate_autocrypt_key_transfer(&self, account_id: u32) -> Result<String> {
707-
let ctx = self.get_context(account_id).await?;
708-
deltachat::imex::initiate_key_transfer(&ctx).await
709-
}
710-
711-
async fn continue_autocrypt_key_transfer(
712-
&self,
713-
account_id: u32,
714-
message_id: u32,
715-
setup_code: String,
716-
) -> Result<()> {
717-
let ctx = self.get_context(account_id).await?;
718-
deltachat::imex::continue_key_transfer(&ctx, MsgId::new(message_id), &setup_code).await
719-
}
720-
721702
// ---------------------------------------------
722703
// chat list
723704
// ---------------------------------------------

deltachat-jsonrpc/src/api/types/message.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ pub struct MessageObject {
6868
/// if `show_padlock` is `false`,
6969
/// and nothing if it is `true`.
7070
show_padlock: bool,
71-
is_setupmessage: bool,
7271
is_info: bool,
7372
is_forwarded: bool,
7473

@@ -88,8 +87,6 @@ pub struct MessageObject {
8887
override_sender_name: Option<String>,
8988
sender: ContactObject,
9089

91-
setup_code_begin: Option<String>,
92-
9390
file: Option<String>,
9491
file_mime: Option<String>,
9592

@@ -226,7 +223,6 @@ impl MessageObject {
226223

227224
subject: message.get_subject().to_owned(),
228225
show_padlock: message.get_showpadlock(),
229-
is_setupmessage: message.is_setupmessage(),
230226
is_info: message.is_info(),
231227
is_forwarded: message.is_forwarded(),
232228
is_bot: message.is_bot(),
@@ -243,8 +239,6 @@ impl MessageObject {
243239
override_sender_name,
244240
sender,
245241

246-
setup_code_begin: message.get_setupcodebegin(context).await,
247-
248242
file: match message.get_file(context) {
249243
Some(path_buf) => path_buf.to_str().map(|s| s.to_owned()),
250244
None => None,

deltachat-repl/src/cmdline.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
302302
// TODO: reuse commands definition in main.rs.
303303
"imex" => println!(
304304
"====================Import/Export commands==\n\
305-
initiate-key-transfer\n\
306-
get-setupcodebegin <msg-id>\n\
307-
continue-key-transfer <msg-id> <setup-code>\n\
308305
has-backup\n\
309306
export-backup\n\
310307
import-backup <backup-file>\n\
@@ -408,34 +405,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
408405
============================================="
409406
),
410407
},
411-
"initiate-key-transfer" => match initiate_key_transfer(&context).await {
412-
Ok(setup_code) => {
413-
println!("Setup code for the transferred setup message: {setup_code}",)
414-
}
415-
Err(err) => bail!("Failed to generate setup code: {err}"),
416-
},
417-
"get-setupcodebegin" => {
418-
ensure!(!arg1.is_empty(), "Argument <msg-id> missing.");
419-
let msg_id: MsgId = MsgId::new(arg1.parse()?);
420-
let msg = Message::load_from_db(&context, msg_id).await?;
421-
if msg.is_setupmessage() {
422-
let setupcodebegin = msg.get_setupcodebegin(&context).await;
423-
println!(
424-
"The setup code for setup message {} starts with: {}",
425-
msg_id,
426-
setupcodebegin.unwrap_or_default(),
427-
);
428-
} else {
429-
bail!("{msg_id} is no setup message.",);
430-
}
431-
}
432-
"continue-key-transfer" => {
433-
ensure!(
434-
!arg1.is_empty() && !arg2.is_empty(),
435-
"Arguments <msg-id> <setup-code> expected"
436-
);
437-
continue_key_transfer(&context, MsgId::new(arg1.parse()?), arg2).await?;
438-
}
439408
"has-backup" => {
440409
has_backup(&context, blobdir).await?;
441410
}

deltachat-repl/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ impl Completer for DcHelper {
149149
}
150150
}
151151

152-
const IMEX_COMMANDS: [&str; 13] = [
153-
"initiate-key-transfer",
154-
"get-setupcodebegin",
155-
"continue-key-transfer",
152+
const IMEX_COMMANDS: [&str; 10] = [
156153
"has-backup",
157154
"export-backup",
158155
"import-backup",

deltachat-rpc-client/src/deltachat_rpc_client/account.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,6 @@ def import_self_keys(self, path) -> None:
483483
passphrase = "" # Importing passphrase-protected keys is currently not supported.
484484
self._rpc.import_self_keys(self.id, str(path), passphrase)
485485

486-
def initiate_autocrypt_key_transfer(self) -> None:
487-
"""Send Autocrypt Setup Message."""
488-
return self._rpc.initiate_autocrypt_key_transfer(self.id)
489-
490486
def ice_servers(self) -> list:
491487
"""Return ICE servers for WebRTC configuration."""
492488
ice_servers_json = self._rpc.ice_servers(self.id)

deltachat-rpc-client/src/deltachat_rpc_client/message.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ def exists(self) -> bool:
7272
"""Return True if the message exists."""
7373
return bool(self._rpc.get_existing_msg_ids(self.account.id, [self.id]))
7474

75-
def continue_autocrypt_key_transfer(self, setup_code: str) -> None:
76-
"""Continue the Autocrypt Setup Message key transfer.
77-
78-
This function can be called on received Autocrypt Setup Message
79-
to import the key encrypted with the provided setup code.
80-
"""
81-
self._rpc.continue_autocrypt_key_transfer(self.account.id, self.id, setup_code)
82-
8375
def send_webxdc_status_update(self, update: Union[dict, str], description: str) -> None:
8476
"""Send a webxdc status update. This message must be a webxdc."""
8577
if not isinstance(update, str):

0 commit comments

Comments
 (0)