Skip to content

Commit cc0006c

Browse files
committed
api!: remove functions for sending and receiving Autocrypt Setup Message
1 parent cff0192 commit cc0006c

File tree

28 files changed

+23
-1031
lines changed

28 files changed

+23
-1031
lines changed

deltachat-ffi/deltachat.h

Lines changed: 4 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,76 +2494,6 @@ void dc_imex (dc_context_t* context, int what, c
24942494
char* dc_imex_has_backup (dc_context_t* context, const char* dir);
24952495

24962496

2497-
/**
2498-
* Initiate Autocrypt Setup Transfer.
2499-
* Before starting the setup transfer with this function, the user should be asked:
2500-
*
2501-
* ~~~
2502-
* "An 'Autocrypt Setup Message' securely shares your end-to-end setup with other Autocrypt-compliant apps.
2503-
* The setup will be encrypted by a setup code which is displayed here and must be typed on the other device.
2504-
* ~~~
2505-
*
2506-
* After that, this function should be called to send the Autocrypt Setup Message.
2507-
* The function creates the setup message and adds it to outgoing message queue.
2508-
* The message is sent asynchronously.
2509-
*
2510-
* The required setup code is returned in the following format:
2511-
*
2512-
* ~~~
2513-
* 1234-1234-1234-1234-1234-1234-1234-1234-1234
2514-
* ~~~
2515-
*
2516-
* The setup code should be shown to the user then:
2517-
*
2518-
* ~~~
2519-
* "Your key has been sent to yourself. Switch to the other device and
2520-
* open the setup message. You should be prompted for a setup code. Type
2521-
* the following digits into the prompt:
2522-
*
2523-
* 1234 - 1234 - 1234 -
2524-
* 1234 - 1234 - 1234 -
2525-
* 1234 - 1234 - 1234
2526-
*
2527-
* Once you're done, your other device will be ready to use Autocrypt."
2528-
* ~~~
2529-
*
2530-
* On the _other device_ you will call dc_continue_key_transfer() then
2531-
* for setup messages identified by dc_msg_is_setupmessage().
2532-
*
2533-
* For more details about the Autocrypt setup process, please refer to
2534-
* https://autocrypt.org/en/latest/level1.html#autocrypt-setup-message
2535-
*
2536-
* @memberof dc_context_t
2537-
* @param context The context object.
2538-
* @return The setup code. Must be released using dc_str_unref() after usage.
2539-
* On errors, e.g. if the message could not be sent, NULL is returned.
2540-
*/
2541-
char* dc_initiate_key_transfer (dc_context_t* context);
2542-
2543-
2544-
/**
2545-
* Continue the Autocrypt Key Transfer on another device.
2546-
*
2547-
* If you have started the key transfer on another device using dc_initiate_key_transfer()
2548-
* and you've detected a setup message with dc_msg_is_setupmessage(), you should prompt the
2549-
* user for the setup code and call this function then.
2550-
*
2551-
* You can use dc_msg_get_setupcodebegin() to give the user a hint about the code (useful if the user
2552-
* has created several messages and should not enter the wrong code).
2553-
*
2554-
* @memberof dc_context_t
2555-
* @param context The context object.
2556-
* @param msg_id The ID of the setup message to decrypt.
2557-
* @param setup_code The setup code entered by the user. This is the same setup code as returned from
2558-
* dc_initiate_key_transfer() on the other device.
2559-
* There is no need to format the string correctly, the function will remove all spaces and other characters and
2560-
* insert the `-` characters at the correct places.
2561-
* @return 1=key successfully decrypted and imported; both devices will use the same key now;
2562-
* 0=key transfer failed e.g. due to a bad setup code.
2563-
*/
2564-
int dc_continue_key_transfer (dc_context_t* context, uint32_t msg_id, const char* setup_code);
2565-
2566-
25672497
/**
25682498
* Signal an ongoing process to stop.
25692499
*
@@ -4682,7 +4612,10 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
46824612
#define DC_INFO_GROUP_IMAGE_CHANGED 3
46834613
#define DC_INFO_MEMBER_ADDED_TO_GROUP 4
46844614
#define DC_INFO_MEMBER_REMOVED_FROM_GROUP 5
4615+
4616+
// Deprecated as of 2026-03-16, not used for new messages.
46854617
#define DC_INFO_AUTOCRYPT_SETUP_MESSAGE 6
4618+
46864619
#define DC_INFO_SECURE_JOIN_MESSAGE 7
46874620
#define DC_INFO_LOCATIONSTREAMING_ENABLED 8
46884621
#define DC_INFO_LOCATION_ONLY 9
@@ -4712,40 +4645,6 @@ uint32_t dc_msg_get_info_contact_id (const dc_msg_t* msg);
47124645
char* dc_msg_get_webxdc_href (const dc_msg_t* msg);
47134646

47144647

4715-
/**
4716-
* Check if the message is an Autocrypt Setup Message.
4717-
*
4718-
* Setup messages should be shown in an unique way e.g. using a different text color.
4719-
* On a click or another action, the user should be prompted for the setup code
4720-
* which is forwarded to dc_continue_key_transfer() then.
4721-
*
4722-
* Setup message are typically generated by dc_initiate_key_transfer() on another device.
4723-
*
4724-
* @memberof dc_msg_t
4725-
* @param msg The message object.
4726-
* @return 1=message is a setup message, 0=no setup message.
4727-
* For setup messages, dc_msg_get_viewtype() returns #DC_MSG_FILE.
4728-
*/
4729-
int dc_msg_is_setupmessage (const dc_msg_t* msg);
4730-
4731-
4732-
/**
4733-
* Get the first characters of the setup code.
4734-
*
4735-
* Typically, this is used to pre-fill the first entry field of the setup code.
4736-
* If the user has several setup messages, he can be sure typing in the correct digits.
4737-
*
4738-
* To check, if a message is a setup message, use dc_msg_is_setupmessage().
4739-
* To decrypt a secret key from a setup message, use dc_continue_key_transfer().
4740-
*
4741-
* @memberof dc_msg_t
4742-
* @param msg The message object.
4743-
* @return Typically the first two digits of the setup code or an empty string if unknown.
4744-
* NULL is never returned. Must be released using dc_str_unref() when done.
4745-
*/
4746-
char* dc_msg_get_setupcodebegin (const dc_msg_t* msg);
4747-
4748-
47494648
/**
47504649
* Gets the error status of the message.
47514650
* If there is no error associated with the message, NULL is returned.
@@ -6339,7 +6238,7 @@ void dc_event_unref(dc_event_t* event);
63396238
* should not be disturbed by a dialog or so. Instead, use a bubble or so.
63406239
*
63416240
* However, for ongoing processes (e.g. dc_configure())
6342-
* or for functions that are expected to fail (e.g. dc_continue_key_transfer())
6241+
* or for functions that are expected to fail
63436242
* it might be better to delay showing these events until the function has really
63446243
* failed (returned false). It should be sufficient to report only the _last_ error
63456244
* in a message box then.

deltachat-ffi/src/lib.rs

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,45 +2446,6 @@ pub unsafe extern "C" fn dc_imex_has_backup(
24462446
}
24472447
}
24482448

2449-
#[no_mangle]
2450-
pub unsafe extern "C" fn dc_initiate_key_transfer(context: *mut dc_context_t) -> *mut libc::c_char {
2451-
if context.is_null() {
2452-
eprintln!("ignoring careless call to dc_initiate_key_transfer()");
2453-
return ptr::null_mut(); // NULL explicitly defined as "error"
2454-
}
2455-
let ctx = &*context;
2456-
2457-
match block_on(imex::initiate_key_transfer(ctx))
2458-
.context("dc_initiate_key_transfer()")
2459-
.log_err(ctx)
2460-
{
2461-
Ok(res) => res.strdup(),
2462-
Err(_) => ptr::null_mut(),
2463-
}
2464-
}
2465-
2466-
#[no_mangle]
2467-
pub unsafe extern "C" fn dc_continue_key_transfer(
2468-
context: *mut dc_context_t,
2469-
msg_id: u32,
2470-
setup_code: *const libc::c_char,
2471-
) -> libc::c_int {
2472-
if context.is_null() || msg_id <= constants::DC_MSG_ID_LAST_SPECIAL || setup_code.is_null() {
2473-
eprintln!("ignoring careless call to dc_continue_key_transfer()");
2474-
return 0;
2475-
}
2476-
let ctx = &*context;
2477-
2478-
block_on(imex::continue_key_transfer(
2479-
ctx,
2480-
MsgId::new(msg_id),
2481-
&to_string_lossy(setup_code),
2482-
))
2483-
.context("dc_continue_key_transfer")
2484-
.log_err(ctx)
2485-
.is_ok() as libc::c_int
2486-
}
2487-
24882449
#[no_mangle]
24892450
pub unsafe extern "C" fn dc_stop_ongoing_process(context: *mut dc_context_t) {
24902451
if context.is_null() {
@@ -3807,16 +3768,6 @@ pub unsafe extern "C" fn dc_msg_get_webxdc_href(msg: *mut dc_msg_t) -> *mut libc
38073768
ffi_msg.message.get_webxdc_href().strdup()
38083769
}
38093770

3810-
#[no_mangle]
3811-
pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg_t) -> libc::c_int {
3812-
if msg.is_null() {
3813-
eprintln!("ignoring careless call to dc_msg_is_setupmessage()");
3814-
return 0;
3815-
}
3816-
let ffi_msg = &*msg;
3817-
ffi_msg.message.is_setupmessage().into()
3818-
}
3819-
38203771
#[no_mangle]
38213772
pub unsafe extern "C" fn dc_msg_has_html(msg: *mut dc_msg_t) -> libc::c_int {
38223773
if msg.is_null() {
@@ -3827,20 +3778,6 @@ pub unsafe extern "C" fn dc_msg_has_html(msg: *mut dc_msg_t) -> libc::c_int {
38273778
ffi_msg.message.has_html().into()
38283779
}
38293780

3830-
#[no_mangle]
3831-
pub unsafe extern "C" fn dc_msg_get_setupcodebegin(msg: *mut dc_msg_t) -> *mut libc::c_char {
3832-
if msg.is_null() {
3833-
eprintln!("ignoring careless call to dc_msg_get_setupcodebegin()");
3834-
return "".strdup();
3835-
}
3836-
let ffi_msg = &*msg;
3837-
let ctx = &*ffi_msg.context;
3838-
3839-
block_on(ffi_msg.message.get_setupcodebegin(ctx))
3840-
.unwrap_or_default()
3841-
.strdup()
3842-
}
3843-
38443781
#[no_mangle]
38453782
pub unsafe extern "C" fn dc_msg_set_text(msg: *mut dc_msg_t, text: *const libc::c_char) {
38463783
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)