feat: update normalize_nonce

This commit is contained in:
2023-08-26 22:59:22 +08:00
parent 03b1167537
commit d867d1d1ca

View File

@@ -137,6 +137,11 @@ impl Aes128GcmStreamEncryptor {
fn normalize_nonce(&mut self, nonce_bytes: &[u8]) -> (u128, u128) { fn normalize_nonce(&mut self, nonce_bytes: &[u8]) -> (u128, u128) {
let ghash_key = self.ghash_key(); let ghash_key = self.ghash_key();
normalize_nonce(ghash_key, nonce_bytes)
}
}
fn normalize_nonce(ghash_key: u128, nonce_bytes: &[u8]) -> (u128, u128) {
let nonce = u8to128(nonce_bytes); let nonce = u8to128(nonce_bytes);
let normalized_nonce = match nonce_bytes.len() == 12 { let normalized_nonce = match nonce_bytes.len() == 12 {
true => { true => {
@@ -153,8 +158,6 @@ impl Aes128GcmStreamEncryptor {
}; };
(ghash_key, normalized_nonce) (ghash_key, normalized_nonce)
} }
}
// R = 11100001 || 0(120) // R = 11100001 || 0(120)
const R: u128 = 0b11100001 << 120; const R: u128 = 0b11100001 << 120;