feat: clean code
This commit is contained in:
@@ -5,7 +5,10 @@ use std::time::{Instant, SystemTime};
|
||||
|
||||
use clap::Args;
|
||||
use openpgp_card::crypto_data::Cryptogram;
|
||||
use rust_util::{debugging, failure, iff, information, opt_result, println_ex, simple_error, success, util_msg, util_size, warning, XResult};
|
||||
use rust_util::{
|
||||
debugging, failure, iff, information, opt_result, println_ex, simple_error, success,
|
||||
util_msg, util_size, warning, XResult,
|
||||
};
|
||||
use rust_util::util_time::UnixEpochTime;
|
||||
use x509_parser::prelude::FromDer;
|
||||
use x509_parser::x509::SubjectPublicKeyInfo;
|
||||
@@ -132,7 +135,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
None => "sha256",
|
||||
Some(algo) => algo.as_str(),
|
||||
};
|
||||
if cmd_decrypt.digest_file { DigestWrite::from_algo(digest_algorithm)?; } // QUICK CHECK
|
||||
if cmd_decrypt.digest_file { DigestWrite::from_algo(digest_algorithm)?; } // FAST CHECK
|
||||
|
||||
let selected_envelop = select_envelop(&meta, config)?;
|
||||
|
||||
@@ -146,7 +149,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
let enc_meta = parse_encrypted_meta(&meta, cryptor, &key_nonce)?;
|
||||
parse_encrypted_comment(&meta, cryptor, &key_nonce)?;
|
||||
|
||||
// Decrypt to output
|
||||
// Decrypt to output
|
||||
if cmd_decrypt.direct_print {
|
||||
if meta.file_length > 10 * 1024 {
|
||||
warning!("File too large(more than 10K) cannot direct print on console.");
|
||||
@@ -168,7 +171,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
return Ok(meta.file_length);
|
||||
}
|
||||
|
||||
// Digest file
|
||||
// Digest file
|
||||
if cmd_decrypt.digest_file {
|
||||
let mut digest_write = DigestWrite::from_algo(digest_algorithm)?;
|
||||
let _ = decrypt_file(
|
||||
@@ -184,7 +187,7 @@ pub fn decrypt_single(config: &Option<TinyEncryptConfig>,
|
||||
return Ok(0);
|
||||
}
|
||||
|
||||
// Decrypt to file
|
||||
// Decrypt to file
|
||||
let compressed_desc = iff!(meta.compress, " [compressed]", "");
|
||||
let start = Instant::now();
|
||||
|
||||
@@ -363,7 +366,7 @@ fn try_decrypt_key_pgp(envelop: &TinyEncryptEnvelop, pin: &Option<String>) -> XR
|
||||
util_pgp::read_and_verify_openpgp_pin(&mut trans, pin)?;
|
||||
|
||||
let pgp_envelop = &envelop.encrypted_key;
|
||||
debugging!("PGP envelop: {}", &pgp_envelop);
|
||||
debugging!("PGP envelop: {}", pgp_envelop);
|
||||
let pgp_envelop_bytes = opt_result!(util::decode_base64(pgp_envelop), "Decode PGP envelop failed: {}");
|
||||
|
||||
let key = trans.decipher(Cryptogram::RSA(&pgp_envelop_bytes))?;
|
||||
|
||||
Reference in New Issue
Block a user