mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-23 19:48:19 +00:00
Add PacketKey::decrypt() method
This commit is contained in:
+7
-1
@@ -1,7 +1,7 @@
|
||||
use bytes::{BigEndian, BufMut};
|
||||
|
||||
use ring::{
|
||||
aead::{self, AES_128_GCM, SealingKey},
|
||||
aead::{self, AES_128_GCM, OpeningKey, SealingKey},
|
||||
digest::SHA256,
|
||||
hkdf,
|
||||
hmac::SigningKey,
|
||||
@@ -39,6 +39,12 @@ impl PacketKey {
|
||||
let nonce = &self.data[self.split..];
|
||||
aead::seal_in_place(&key, nonce, ad, in_out, out_suffix_capacity).unwrap()
|
||||
}
|
||||
|
||||
pub fn decrypt<'a>(&self, ad: &[u8], input: &'a mut [u8]) -> &'a [u8] {
|
||||
let key = OpeningKey::new(self.alg, &self.data[..self.split]).unwrap();
|
||||
let nonce = &self.data[self.split..];
|
||||
aead::open_in_place(&key, nonce, ad, 0, input).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
fn client_handshake_secret(conn_id: u64) -> Vec<u8> {
|
||||
|
||||
Reference in New Issue
Block a user