Skip to content

Commit

Permalink
proto: abstract more over ring dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Sep 16, 2024
1 parent 7d047e8 commit 2039e2f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions quinn-proto/src/crypto/ring.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ring::{aead, hkdf, hmac};
use ring::{aead, error, hkdf, hmac};

use crate::crypto::{self, CryptoError};

Expand Down Expand Up @@ -31,8 +31,8 @@ impl crypto::HandshakeTokenKey for hkdf::Prk {

impl crypto::AeadKey for aead::LessSafeKey {
fn seal(&self, data: &mut Vec<u8>, additional_data: &[u8]) -> Result<(), CryptoError> {
let aad = ring::aead::Aad::from(additional_data);
let zero_nonce = ring::aead::Nonce::assume_unique_for_key([0u8; 12]);
let aad = aead::Aad::from(additional_data);
let zero_nonce = aead::Nonce::assume_unique_for_key([0u8; 12]);
Ok(self.seal_in_place_append_tag(zero_nonce, aad, data)?)
}

Expand All @@ -41,14 +41,14 @@ impl crypto::AeadKey for aead::LessSafeKey {
data: &'a mut [u8],
additional_data: &[u8],
) -> Result<&'a mut [u8], CryptoError> {
let aad = ring::aead::Aad::from(additional_data);
let zero_nonce = ring::aead::Nonce::assume_unique_for_key([0u8; 12]);
let aad = aead::Aad::from(additional_data);
let zero_nonce = aead::Nonce::assume_unique_for_key([0u8; 12]);
Ok(self.open_in_place(zero_nonce, aad, data)?)
}
}

impl From<ring::error::Unspecified> for CryptoError {
fn from(_: ring::error::Unspecified) -> Self {
impl From<error::Unspecified> for CryptoError {
fn from(_: error::Unspecified) -> Self {
Self
}
}

0 comments on commit 2039e2f

Please sign in to comment.