feat: comments
This commit is contained in:
@@ -14,16 +14,16 @@ use crate::util_progress::Progress;
|
|||||||
|
|
||||||
#[derive(Debug, Args)]
|
#[derive(Debug, Args)]
|
||||||
pub struct CmdDirectDecrypt {
|
pub struct CmdDirectDecrypt {
|
||||||
/// Files in
|
/// File input
|
||||||
#[arg(long, short = 'i')]
|
#[arg(long, short = 'i')]
|
||||||
pub file_in: PathBuf,
|
pub file_in: PathBuf,
|
||||||
/// Files output
|
/// File output
|
||||||
#[arg(long, short = 'o')]
|
#[arg(long, short = 'o')]
|
||||||
pub file_out: PathBuf,
|
pub file_out: PathBuf,
|
||||||
/// Remove source file
|
/// Remove source file
|
||||||
#[arg(long, short = 'R')]
|
#[arg(long, short = 'R')]
|
||||||
pub remove_file: bool,
|
pub remove_file: bool,
|
||||||
/// Key in HEX
|
/// Key in HEX (32 bytes)
|
||||||
#[arg(long, short = 'k')]
|
#[arg(long, short = 'k')]
|
||||||
pub key: String,
|
pub key: String,
|
||||||
}
|
}
|
||||||
@@ -36,10 +36,12 @@ impl Drop for CmdDirectDecrypt {
|
|||||||
|
|
||||||
const DIRECT_ENCRYPT_MAGIC: &str = "e2c50001";
|
const DIRECT_ENCRYPT_MAGIC: &str = "e2c50001";
|
||||||
|
|
||||||
// Format
|
// Direct decrypt file format:
|
||||||
// [4 bytes] - magic 0xe2c50001
|
// [4 bytes] - magic 0xe2 0xc5 0x00 0x01
|
||||||
// [32 bytes] - key digest
|
// [32 bytes] - key digest
|
||||||
// [12 bytes] - nonce
|
// [12 bytes] - nonce
|
||||||
|
// [n bytes] - ciphertext
|
||||||
|
// [16 bytes] - tag
|
||||||
pub fn direct_decrypt(cmd_direct_decrypt: CmdDirectDecrypt) -> XResult<()> {
|
pub fn direct_decrypt(cmd_direct_decrypt: CmdDirectDecrypt) -> XResult<()> {
|
||||||
let key = opt_result!(hex::decode(&cmd_direct_decrypt.key), "Parse key failed: {}");
|
let key = opt_result!(hex::decode(&cmd_direct_decrypt.key), "Parse key failed: {}");
|
||||||
if key.len() != 32 {
|
if key.len() != 32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user