feat: decrypt ecdh works

This commit is contained in:
2023-09-07 23:12:04 +08:00
parent 3a4af50e27
commit 3d40730cb5
6 changed files with 799 additions and 52 deletions

View File

@@ -5,12 +5,29 @@ use base64::Engine;
use base64::engine::general_purpose;
use rust_util::{warning, XResult};
pub const ENC_AES256_GCM_P256: &str = "aes256-gcm-p256";
pub const TINY_ENC_FILE_EXT: &str = ".tinyenc";
pub fn simple_kdf(input: &[u8]) -> Vec<u8> {
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
let input = hex::decode(sha256::digest(input)).unwrap();
input
}
pub fn decode_base64(input: &str) -> XResult<Vec<u8>> {
Ok(general_purpose::STANDARD.decode(input)?)
}
pub fn decode_base64_url_no_pad(input: &str) -> XResult<Vec<u8>> {
Ok(general_purpose::URL_SAFE_NO_PAD.decode(input)?)
}
pub fn read_number(hint: &str, from: usize, to: usize) -> usize {
loop {
print!("{} ({}-{}): ", hint, from, to);