Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #114

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ percent-encode = ["url"]
[dependencies]
time = "0.1"
url = { version = "1.0", optional = true }
ring = { version = "0.13.0", optional = true }
base64 = { version = "0.9.0", optional = true }
ring = { version = "0.14.0", optional = true }
base64 = { version = "0.10.0", optional = true }

[package.metadata.docs.rs]
all-features = true
8 changes: 5 additions & 3 deletions src/secure/private.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use secure::ring::aead::{seal_in_place, open_in_place, Algorithm, AES_256_GCM};
use secure::ring::aead::{seal_in_place, open_in_place, Algorithm, AES_256_GCM, Nonce, Aad};
use secure::ring::aead::{OpeningKey, SealingKey};
use secure::ring::rand::{SecureRandom, SystemRandom};
use secure::{base64, Key};
Expand Down Expand Up @@ -49,7 +49,8 @@ impl<'a> PrivateJar<'a> {
let ad = name.as_bytes();
let key = OpeningKey::new(ALGO, &self.key).expect("opening key");
let (nonce, sealed) = data.split_at_mut(NONCE_LEN);
let unsealed = open_in_place(&key, nonce, ad, 0, sealed)
let nonce = Nonce::try_assume_unique_for_key(nonce).unwrap();
let unsealed = open_in_place(&key, nonce, Aad::from(ad), 0, sealed)
.map_err(|_| "invalid key/nonce/value: bad seal")?;

::std::str::from_utf8(unsealed)
Expand Down Expand Up @@ -155,13 +156,14 @@ impl<'a> PrivateJar<'a> {
// Randomly generate the nonce, then copy the cookie value as input.
let (nonce, in_out) = data.split_at_mut(NONCE_LEN);
SystemRandom::new().fill(nonce).expect("couldn't random fill nonce");
let nonce = Nonce::try_assume_unique_for_key(nonce).unwrap();
in_out[..cookie_val.len()].copy_from_slice(cookie_val);

// Use cookie's name as associated data to prevent value swapping.
let ad = cookie.name().as_bytes();

// Perform the actual sealing operation and get the output length.
seal_in_place(&key, nonce, ad, in_out, overhead).expect("in-place seal")
seal_in_place(&key, nonce, Aad::from(ad), in_out, overhead).expect("in-place seal")
};

// Base64 encode the nonce and encrypted value.
Expand Down