feat: update normalize_nonce
This commit is contained in:
@@ -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 => {
|
||||||
@@ -152,10 +157,8 @@ 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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user