3 个版本

0.0.3 2024 年 6 月 27 日
0.0.2 2024 年 6 月 25 日
0.0.1 2024 年 6 月 25 日

#1497 in 密码学


2 crates 使用

BSD-2-Clause

73KB
1K SLoC

这是什么?

volaris-crypto 是一个用于管理符合 volaris 格式的加密函数和头的库。

安全性

volaris-crypto 使用现代、安全且经过审计1 的 AEADs 进行加密和解密。

您可以在 NCC Group 的网站上找到 AES-256-GCM 和 XChaCha20-Poly1305 的审计报告。

谁使用 volaris-crypto?

此库由 volaris 实现,volaris 是一个安全的多接口文件加密工具。

volaris-crypto 使得将 volaris 格式集成到您的项目中变得简单(如果您想看到某个功能,请随时在 GitHub 上提出问题)。

功能

  • 加密/解密方便函数
  • 2 个 AEADs(XChaCha20-Poly1305、AES-256-GCM)1 Deoxys-II-256 是之前的 AEAD,但现在已禁用。
  • 轻松管理加密头(不再需要担心 nonce 的存储位置!)
  • 使用安全参数轻松 argon2id 哈希
  • 使用安全参数和 BLAKE3 的轻松 balloon 哈希
  • 频繁更新和功能添加!

示例

反序列化头

let header_bytes: [u8; 64] = [
  222, 2, 14, 1, 12, 1, 142, 88, 243, 144, 119, 187, 189, 190, 121, 90, 211, 56, 185, 14, 76,
  45, 16, 5, 237, 72, 7, 203, 13, 145, 13, 155, 210, 29, 128, 142, 241, 233, 42, 168, 243,
  129, 0, 0, 0, 0, 0, 0, 214, 45, 3, 4, 11, 212, 129, 123, 192, 157, 185, 109, 151, 225, 233,
  161,
];

let mut cursor = Cursor::new(header_bytes);

// the cursor may be a file, this is just an example

let (header, aad) = Header::deserialize(&mut cursor).unwrap();

将头写入文件

let mut output_file = File::create("test").unwrap();
header.write(&mut output_file).unwrap();

内存中的加密和解密

// obviously the key should contain data, not be an empty vec
let raw_key = Protected::new(vec![0u8; 128]);
let salt = gen_salt();
let key = balloon_hash(raw_key, &salt, &HeaderVersion::V4).unwrap();
let cipher = Ciphers::initialize(key, &Algorithm::XChaCha20Poly1305).unwrap();

let secret = "super secret information";

let nonce = gen_nonce(&Algorithm::XChaCha20Poly1305, &Mode::MemoryMode);
let encrypted_data = cipher.encrypt(&nonce, secret.as_bytes()).unwrap();

let decrypted_data = cipher.decrypt(&nonce, encrypted_data.as_slice()).unwrap();

assert_eq!(secret, decrypted_data);

您可以在项目的主要文档中了解更多关于 volaris、volaris-crypto 和技术细节的信息!

谢谢!

volaris-crypto 独家使用 RustCrypto 团队提供的 AEADs,因此我想向他们表示衷心的感谢(没有他们这是不可能的!)

依赖项

~4–12MB
~135K SLoC