mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
use safe logging, and add some info on the processed key (this is WIP and needs to be removed)
This commit is contained in:
@@ -462,5 +462,6 @@ class TestOnlineAccount:
|
|||||||
msg = ac2.get_message_by_id(ev[2])
|
msg = ac2.get_message_by_id(ev[2])
|
||||||
assert msg.is_setup_message()
|
assert msg.is_setup_message()
|
||||||
print("*************** Incoming ASM File at: ", msg.filename)
|
print("*************** Incoming ASM File at: ", msg.filename)
|
||||||
|
print("*************** Setup Code: ", setup_code)
|
||||||
msg.continue_key_transfer(setup_code)
|
msg.continue_key_transfer(setup_code)
|
||||||
assert ac1.get_info()["fingerprint"] == ac2.get_info()["fingerprint"]
|
assert ac1.get_info()["fingerprint"] == ac2.get_info()["fingerprint"]
|
||||||
|
|||||||
@@ -362,10 +362,10 @@ pub unsafe fn dc_continue_key_transfer(
|
|||||||
}
|
}
|
||||||
|| *filename.offset(0isize) as libc::c_int == 0i32
|
|| *filename.offset(0isize) as libc::c_int == 0i32
|
||||||
{
|
{
|
||||||
dc_log_error(
|
error!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"Message is no Autocrypt Setup Message.\x00" as *const u8 as *const libc::c_char,
|
"Message is no Autocrypt Setup Message.",
|
||||||
);
|
);
|
||||||
} else if 0
|
} else if 0
|
||||||
== dc_read_file(
|
== dc_read_file(
|
||||||
@@ -377,28 +377,26 @@ pub unsafe fn dc_continue_key_transfer(
|
|||||||
|| filecontent.is_null()
|
|| filecontent.is_null()
|
||||||
|| filebytes <= 0
|
|| filebytes <= 0
|
||||||
{
|
{
|
||||||
dc_log_error(
|
error!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"Cannot read Autocrypt Setup Message file.\x00" as *const u8
|
"Cannot read Autocrypt Setup Message file.",
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
norm_sc = dc_normalize_setup_code(context, setup_code);
|
norm_sc = dc_normalize_setup_code(context, setup_code);
|
||||||
if norm_sc.is_null() {
|
if norm_sc.is_null() {
|
||||||
dc_log_warning(
|
warn!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"Cannot normalize Setup Code.\x00" as *const u8 as *const libc::c_char,
|
"Cannot normalize Setup Code.",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
armored_key = dc_decrypt_setup_file(context, norm_sc, filecontent);
|
armored_key = dc_decrypt_setup_file(context, norm_sc, filecontent);
|
||||||
if armored_key.is_null() {
|
if armored_key.is_null() {
|
||||||
dc_log_warning(
|
warn!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"Cannot decrypt Autocrypt Setup Message.\x00" as *const u8
|
"Cannot decrypt Autocrypt Setup Message.",
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
);
|
||||||
} else if !(0 == set_self_key(context, armored_key, 1i32)) {
|
} else if !(0 == set_self_key(context, armored_key, 1i32)) {
|
||||||
/*set default*/
|
/*set default*/
|
||||||
@@ -433,6 +431,8 @@ unsafe fn set_self_key(
|
|||||||
let mut buf_base64: *const libc::c_char = 0 as *const libc::c_char;
|
let mut buf_base64: *const libc::c_char = 0 as *const libc::c_char;
|
||||||
let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
let mut stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
|
||||||
let mut self_addr: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut self_addr: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
|
info!(context, 0, "armored key: {}", as_str(armored));
|
||||||
|
|
||||||
buf = dc_strdup(armored);
|
buf = dc_strdup(armored);
|
||||||
if 0 == dc_split_armored_data(
|
if 0 == dc_split_armored_data(
|
||||||
buf,
|
buf,
|
||||||
@@ -446,10 +446,10 @@ unsafe fn set_self_key(
|
|||||||
) != 0i32
|
) != 0i32
|
||||||
|| buf_base64.is_null()
|
|| buf_base64.is_null()
|
||||||
{
|
{
|
||||||
dc_log_warning(
|
warn!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"File does not contain a private key.\x00" as *const u8 as *const libc::c_char,
|
"File does not contain a private key.",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if let Some((private_key, public_key)) = Key::from_base64(
|
if let Some((private_key, public_key)) = Key::from_base64(
|
||||||
@@ -568,6 +568,7 @@ pub unsafe fn dc_decrypt_setup_file(
|
|||||||
let mut indx: size_t = 0i32 as size_t;
|
let mut indx: size_t = 0i32 as size_t;
|
||||||
|
|
||||||
let mut payload: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut payload: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
|
info!(_context, 0, "trying to decrypt ASM file");
|
||||||
fc_buf = dc_strdup(filecontent);
|
fc_buf = dc_strdup(filecontent);
|
||||||
if !(0
|
if !(0
|
||||||
== dc_split_armored_data(
|
== dc_split_armored_data(
|
||||||
|
|||||||
Reference in New Issue
Block a user