feat: update dependencies, optimize
This commit is contained in:
@@ -7,7 +7,7 @@ use std::time::Instant;
|
||||
use clap::Args;
|
||||
use flate2::Compression;
|
||||
use rsa::Pkcs1v15Encrypt;
|
||||
use rust_util::{debugging, failure, iff, information, opt_result, simple_error, success, XResult};
|
||||
use rust_util::{debugging, failure, iff, information, opt_result, simple_error, success, util_size, XResult};
|
||||
use rust_util::util_time::UnixEpochTime;
|
||||
|
||||
use crate::{crypto_cryptor, crypto_simple, util, util_enc_file, util_env, util_p256, util_p384, util_x25519};
|
||||
@@ -194,7 +194,7 @@ fn encrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write, cr
|
||||
None => GzStreamEncoder::new_default(),
|
||||
Some(compress_level) => {
|
||||
if *compress_level > 9 {
|
||||
return simple_error!("Compress level must in range [0, 9]");
|
||||
return simple_error!("Compress level must be in range [0, 9]");
|
||||
}
|
||||
GzStreamEncoder::new(Compression::new(*compress_level))
|
||||
}
|
||||
@@ -221,10 +221,12 @@ fn encrypt_file(file_in: &mut File, file_len: u64, file_out: &mut impl Write, cr
|
||||
};
|
||||
opt_result!(file_out.write_all(&last_block_and_tag), "Write file failed: {}");
|
||||
progress.finish();
|
||||
debugging!("Encrypt finished, total bytes: {}", total_len);
|
||||
debugging!("Encrypt finished, total bytes: {} byte(s)", total_len);
|
||||
if compress {
|
||||
information!("File is compressed: {} byte(s) -> {} byte(s), ratio: {}%",
|
||||
total_len, write_len, util::ratio(write_len, total_len));
|
||||
information!("File is compressed: {} -> {}, ratio: {}%",
|
||||
util_size::get_display_size(total_len as i64),
|
||||
util_size::get_display_size(write_len as i64),
|
||||
util::ratio(write_len, total_len));
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
@@ -309,11 +311,7 @@ fn encrypt_envelop_shared_secret(cryptor: Cryptor,
|
||||
cryptor, &key_nonce, key)?;
|
||||
|
||||
let wrap_key = WrapKey {
|
||||
header: WrapKeyHeader {
|
||||
kid: None,
|
||||
enc: enc_type.to_string(),
|
||||
e_pub_key: util::encode_base64_url_no_pad(ephemeral_spki),
|
||||
},
|
||||
header: WrapKeyHeader::from(enc_type, ephemeral_spki),
|
||||
nonce: nonce.0.clone(),
|
||||
encrypted_data: encrypted_key,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user