feat: encrypt works

This commit is contained in:
2023-09-03 23:09:17 +08:00
parent ef53e1eb2b
commit 8f372057b3
6 changed files with 303 additions and 4 deletions

17
src/lib.rs Normal file
View File

@@ -0,0 +1,17 @@
mod util;
mod encryptor;
pub use encryptor::Sm4GcmStreamEncryptor;
use crate::encryptor::sm4_gcm_aad_encrypt;
#[test]
fn test_encrypt() {
let data = vec![
([0u8; 16], [0u8; 12], &[], &b"hello world", "1587c6137e306fed6a6a5f49539b6dd6fe2b7872c3279636db07c2")
];
for (key, nonce, aad, message, expected) in data {
let encrypted = hex::encode(sm4_gcm_aad_encrypt(key, &nonce, aad, *message));
assert_eq!(expected, &encrypted);
}
}