use safe logging, and add some info on the processed key (this is WIP and needs to be removed)

This commit is contained in:
holger krekel
2019-07-05 13:04:26 +02:00
parent 699b2d48e6
commit dfa2fcda73
2 changed files with 19 additions and 17 deletions

View File

@@ -362,10 +362,10 @@ pub unsafe fn dc_continue_key_transfer(
}
|| *filename.offset(0isize) as libc::c_int == 0i32
{
dc_log_error(
error!(
context,
0i32,
b"Message is no Autocrypt Setup Message.\x00" as *const u8 as *const libc::c_char,
0,
"Message is no Autocrypt Setup Message.",
);
} else if 0
== dc_read_file(
@@ -377,28 +377,26 @@ pub unsafe fn dc_continue_key_transfer(
|| filecontent.is_null()
|| filebytes <= 0
{
dc_log_error(
error!(
context,
0i32,
b"Cannot read Autocrypt Setup Message file.\x00" as *const u8
as *const libc::c_char,
0,
"Cannot read Autocrypt Setup Message file.",
);
} else {
norm_sc = dc_normalize_setup_code(context, setup_code);
if norm_sc.is_null() {
dc_log_warning(
warn!(
context,
0i32,
b"Cannot normalize Setup Code.\x00" as *const u8 as *const libc::c_char,
0,
"Cannot normalize Setup Code.",
);
} else {
armored_key = dc_decrypt_setup_file(context, norm_sc, filecontent);
if armored_key.is_null() {
dc_log_warning(
warn!(
context,
0i32,
b"Cannot decrypt Autocrypt Setup Message.\x00" as *const u8
as *const libc::c_char,
0,
"Cannot decrypt Autocrypt Setup Message.",
);
} else if !(0 == set_self_key(context, armored_key, 1i32)) {
/*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 stmt: *mut sqlite3_stmt = 0 as *mut sqlite3_stmt;
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);
if 0 == dc_split_armored_data(
buf,
@@ -446,10 +446,10 @@ unsafe fn set_self_key(
) != 0i32
|| buf_base64.is_null()
{
dc_log_warning(
warn!(
context,
0i32,
b"File does not contain a private key.\x00" as *const u8 as *const libc::c_char,
0,
"File does not contain a private key.",
);
} else {
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 payload: *mut libc::c_char = 0 as *mut libc::c_char;
info!(_context, 0, "trying to decrypt ASM file");
fc_buf = dc_strdup(filecontent);
if !(0
== dc_split_armored_data(