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

Bump dependencies #114

wants to merge 2 commits into from

Conversation

kpcyrd
Copy link

@kpcyrd kpcyrd commented Jan 29, 2019

This updates both the ring and base64 dependency. The ring dependency is especially imported for me since 0.14 contains important bugfixes that I can't use until every crate in my dependency tree is on 0.14. :)

Related to: rwf2/Rocket#905 and kpcyrd/sn0int#69

Thanks!

@jethrogb
Copy link

jethrogb commented Feb 1, 2019

Needs this patch

diff --git a/src/secure/private.rs b/src/secure/private.rs
index 56dcdbc..9804f40 100644
--- a/src/secure/private.rs
+++ b/src/secure/private.rs
@@ -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};
@@ -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)
@@ -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.

@kpcyrd
Copy link
Author

kpcyrd commented Feb 1, 2019

@jethrogb thank you very much, I forgot to enable the secret feature while running my tests.

@SergioBenitez
Copy link
Member

c41fe46 and c59d94e collectively implement this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants