Skip to content

Commit 914f760

Browse files
ubnt-intrepidSergioBenitez
authored andcommitted
bump ring to 0.14.0
1 parent c253a23 commit 914f760

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ percent-encode = ["url"]
1717
[dependencies]
1818
time = "0.1"
1919
url = { version = "1.0", optional = true }
20-
ring = { version = "0.13.0", optional = true }
20+
ring = { version = "0.14.0", optional = true }
2121
base64 = { version = "0.9.0", optional = true }
2222

2323
[package.metadata.docs.rs]

src/secure/private.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use secure::ring::aead::{seal_in_place, open_in_place, Algorithm, AES_256_GCM};
1+
use secure::ring::aead::{seal_in_place, open_in_place, Aad, Algorithm, Nonce, AES_256_GCM};
22
use secure::ring::aead::{OpeningKey, SealingKey};
33
use secure::ring::rand::{SecureRandom, SystemRandom};
44
use secure::{base64, Key};
@@ -46,9 +46,11 @@ impl<'a> PrivateJar<'a> {
4646
return Err("length of decoded data is <= NONCE_LEN");
4747
}
4848

49-
let ad = name.as_bytes();
49+
let ad = Aad::from(name.as_bytes());
5050
let key = OpeningKey::new(ALGO, &self.key).expect("opening key");
5151
let (nonce, sealed) = data.split_at_mut(NONCE_LEN);
52+
let nonce = Nonce::try_assume_unique_for_key(nonce)
53+
.expect("invalid length of `nonce`");
5254
let unsealed = open_in_place(&key, nonce, ad, 0, sealed)
5355
.map_err(|_| "invalid key/nonce/value: bad seal")?;
5456

@@ -156,9 +158,11 @@ impl<'a> PrivateJar<'a> {
156158
let (nonce, in_out) = data.split_at_mut(NONCE_LEN);
157159
SystemRandom::new().fill(nonce).expect("couldn't random fill nonce");
158160
in_out[..cookie_val.len()].copy_from_slice(cookie_val);
161+
let nonce = Nonce::try_assume_unique_for_key(nonce)
162+
.expect("invalid length of `nonce`");
159163

160164
// Use cookie's name as associated data to prevent value swapping.
161-
let ad = cookie.name().as_bytes();
165+
let ad = Aad::from(cookie.name().as_bytes());
162166

163167
// Perform the actual sealing operation and get the output length.
164168
seal_in_place(&key, nonce, ad, in_out, overhead).expect("in-place seal")

0 commit comments

Comments
 (0)