v-0.2.0-alpha-1 #1

Merged
hatter merged 5 commits from v-0.2.0-alpha-1 into main 2023-09-02 00:14:31 +08:00
2 changed files with 2 additions and 8 deletions
Showing only changes of commit 0ad4e5ce28 - Show all commits

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "aes-gcm-stream" name = "aes-gcm-stream"
version = "0.1.2" version = "0.2.0"
edition = "2021" edition = "2021"
authors = ["Hatter Jiang"] authors = ["Hatter Jiang"]
repository = "https://git.hatter.ink/hatter/aes-gcm-stream" repository = "https://git.hatter.ink/hatter/aes-gcm-stream"
@@ -16,9 +16,7 @@ aes = { version = "0.8.3", features = ["zeroize"] }
ghash = "0.5.0" ghash = "0.5.0"
zeroize = { version = "1.6.0", features = ["zeroize_derive"] } zeroize = { version = "1.6.0", features = ["zeroize_derive"] }
hex = "0.4.3"
[dev-dependencies] [dev-dependencies]
#hex = "0.4.3" hex = "0.4.3"
aes-gcm = { version = "0.10.2", features = ["zeroize"] } aes-gcm = { version = "0.10.2", features = ["zeroize"] }
benchmark-simple = "0.1.8" benchmark-simple = "0.1.8"

View File

@@ -42,7 +42,6 @@ impl $module {
message_len: 0, message_len: 0,
}; };
let (ghash_key, normalized_nonce) = s.normalize_nonce(nonce); let (ghash_key, normalized_nonce) = s.normalize_nonce(nonce);
println!("<<< KEY: {}", hex::encode(ghash_key.to_be_bytes()));
s.ghash_key = ghash_key; s.ghash_key = ghash_key;
s.init_nonce = normalized_nonce; s.init_nonce = normalized_nonce;
s.encryption_nonce = normalized_nonce; s.encryption_nonce = normalized_nonce;
@@ -127,9 +126,7 @@ impl $module {
let mut bs = self.init_nonce.to_be_bytes().clone(); let mut bs = self.init_nonce.to_be_bytes().clone();
let block = Block::<$aesn>::from_mut_slice(&mut bs); let block = Block::<$aesn>::from_mut_slice(&mut bs);
self.crypto.encrypt_block(block); self.crypto.encrypt_block(block);
println!("<<< final enc block: {}", hex::encode(&block.as_slice()));
let tag_trunk = self.ghash_val.to_be_bytes(); let tag_trunk = self.ghash_val.to_be_bytes();
println!("<<< final block: {}", hex::encode(&tag_trunk));
let y = u8to128(&tag_trunk) ^ u8to128(&block.as_slice()); let y = u8to128(&tag_trunk) ^ u8to128(&block.as_slice());
y.to_be_bytes().to_vec() y.to_be_bytes().to_vec()
} }
@@ -141,7 +138,6 @@ impl $module {
let blocks_count = integrality_buffer_slice_len / 16; let blocks_count = integrality_buffer_slice_len / 16;
for i in 0..blocks_count { for i in 0..blocks_count {
let buf = &integrality_buffer_slice[i * 16..(i + 1) * 16]; let buf = &integrality_buffer_slice[i * 16..(i + 1) * 16];
println!("<<< block: {}", hex::encode(buf));
self.ghash_val = gmul_128(self.ghash_val ^ u8to128(buf), self.ghash_key) self.ghash_val = gmul_128(self.ghash_val ^ u8to128(buf), self.ghash_key)
} }
self.integrality_buffer = integrality_buffer_slice[blocks_count * 16..].to_vec(); self.integrality_buffer = integrality_buffer_slice[blocks_count * 16..].to_vec();