Skip to content

Commit 0d5614b

Browse files
committed
api!: remove functions for sending and receiving Autocrypt Setup Message
1 parent 822a99e commit 0d5614b

File tree

16 files changed

+14
-639
lines changed

16 files changed

+14
-639
lines changed

deltachat-ffi/deltachat.h

Lines changed: 0 additions & 70 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
*

deltachat-ffi/src/lib.rs

Lines changed: 0 additions & 39 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() {

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-repl/src/cmdline.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ 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\
306305
get-setupcodebegin <msg-id>\n\
307-
continue-key-transfer <msg-id> <setup-code>\n\
308306
has-backup\n\
309307
export-backup\n\
310308
import-backup <backup-file>\n\
@@ -408,12 +406,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
408406
============================================="
409407
),
410408
},
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-
},
417409
"get-setupcodebegin" => {
418410
ensure!(!arg1.is_empty(), "Argument <msg-id> missing.");
419411
let msg_id: MsgId = MsgId::new(arg1.parse()?);
@@ -429,13 +421,6 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
429421
bail!("{msg_id} is no setup message.",);
430422
}
431423
}
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-
}
439424
"has-backup" => {
440425
has_backup(&context, blobdir).await?;
441426
}

deltachat-repl/src/main.rs

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

152-
const IMEX_COMMANDS: [&str; 13] = [
153-
"initiate-key-transfer",
152+
const IMEX_COMMANDS: [&str; 11] = [
154153
"get-setupcodebegin",
155-
"continue-key-transfer",
156154
"has-backup",
157155
"export-backup",
158156
"import-backup",

deltachat-rpc-client/tests/test_key_transfer.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/chat.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,9 +2844,7 @@ pub(crate) async fn create_send_msg_jobs(context: &Context, msg: &mut Message) -
28442844
let lowercase_from = from.to_lowercase();
28452845

28462846
recipients.retain(|x| x.to_lowercase() != lowercase_from);
2847-
if context.get_config_bool(Config::BccSelf).await?
2848-
|| msg.param.get_cmd() == SystemMessage::AutocryptSetupMessage
2849-
{
2847+
if context.get_config_bool(Config::BccSelf).await? {
28502848
smtp::add_self_recipients(context, &mut recipients, needs_encryption).await?;
28512849
}
28522850

src/constants.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,6 @@ pub(crate) const TIMESTAMP_SENT_TOLERANCE: i64 = 60;
234234
// Newer Delta Chats will remove the prefix as needed.
235235
pub(crate) const EDITED_PREFIX: &str = "✏️";
236236

237-
// Strings needed to render the Autocrypt Setup Message.
238-
// Left untranslated as not being supported/recommended workflow and as translations would require deep knowledge.
239-
pub(crate) const ASM_SUBJECT: &str = "Autocrypt Setup Message";
240-
pub(crate) const ASM_BODY: &str = "This is the Autocrypt Setup Message \
241-
used to transfer your end-to-end setup between clients.
242-
243-
To decrypt and use your setup, \
244-
open the message in an Autocrypt-compliant client \
245-
and enter the setup code presented on the generating device.
246-
247-
If you see this message in a chatmail client (Delta Chat, Arcane Chat, Delta Touch ...), \
248-
use \"Settings / Add Second Device\" instead.";
249-
250237
/// Period between `sql::housekeeping()` runs.
251238
pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;
252239

src/headerdef.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ mod tests {
208208
/// Test that headers are parsed case-insensitively
209209
fn test_get_header_value_case() {
210210
let (headers, _) =
211-
mailparse::parse_headers(b"fRoM: Bob\naUtoCryPt-SeTup-MessAge: v99").unwrap();
211+
mailparse::parse_headers(b"fRoM: Bob\naUtoCryPt-GoSsIp: fooBaR").unwrap();
212212
assert_eq!(
213-
headers.get_header_value(HeaderDef::AutocryptSetupMessage),
214-
Some("v99".to_string())
213+
headers.get_header_value(HeaderDef::AutocryptGossip),
214+
Some("fooBaR".to_string())
215215
);
216216
assert_eq!(
217217
headers.get_header_value(HeaderDef::From_),

src/imap.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,15 +1974,6 @@ async fn needs_move_to_mvbox(
19741974
return Ok(false);
19751975
}
19761976

1977-
if headers
1978-
.get_header_value(HeaderDef::AutocryptSetupMessage)
1979-
.is_some()
1980-
{
1981-
// do not move setup messages;
1982-
// there may be a non-delta device that wants to handle it
1983-
return Ok(false);
1984-
}
1985-
19861977
if has_chat_version {
19871978
Ok(true)
19881979
} else if let Some(parent) = get_prefetch_parent_message(context, headers).await? {

0 commit comments

Comments
 (0)