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

Compatibility with rust-ece breaking API changes #3941

Merged
merged 1 commit into from
Mar 22, 2021
Merged

Conversation

rfk
Copy link
Contributor

@rfk rfk commented Mar 18, 2021

WIP updates for compatibility with the work I'm doing over in mozilla/rust-ece#52

The rust-ece crate has had its interface simplified to remove footguns, let's update to that release and get a few cleanups of our own while we're at it.

@rfk rfk force-pushed the ece-interface-cleanups branch 5 times, most recently from f2a90c1 to 1c66e5b Compare March 19, 2021 07:08
@codecov-io
Copy link

Codecov Report

Merging #3941 (1c66e5b) into main (3924686) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #3941   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        177     177           
  Lines      12142   12135    -7     
=====================================
+ Misses     12142   12135    -7     
Impacted Files Coverage Δ
...nents/fxa-client/src/internal/commands/send_tab.rs 0.00% <0.00%> (ø)
components/support/rc_crypto/src/ece_crypto.rs 0.00% <ø> (ø)
examples/push-livetest/src/livetest.rs 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3924686...1c66e5b. Read the comment docs.

@rfk rfk changed the title WIP adjust for rust-ece interface cleanups Compatibility with rust-ece breaking API changes Mar 22, 2021
@rfk rfk force-pushed the ece-interface-cleanups branch from 1c66e5b to a073394 Compare March 22, 2021 02:36
Copy link
Contributor Author

@rfk rfk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lougeniaC64 could you please take a look at these corresponding changes on the consumer side of the rust-ece crate?

@@ -468,7 +468,7 @@ mod test {
.with_body(body)
.create();
let mut conn = connect(config.clone(), None, None).unwrap();
let channel_id = hex::encode(crate::crypto::get_bytes(16).unwrap());
let channel_id = hex::encode(crate::crypto::get_random_bytes(16).unwrap());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just, I couldn't handle the name of this function - what sort of bytes are we getting??

@@ -50,14 +48,12 @@ impl Key {
}
}

pub fn key_pair(&self) -> error::Result<RcCryptoLocalKeyPair> {
RcCryptoLocalKeyPair::from_raw_components(&self.p256key).map_err(|e| {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we were accidentally biting ourselves here with a bit of bad API design, which meant that we couldn't use the aesgcm scheme without knowing which specific crypto backend was in use by the rust-ece crate. That has been fixed now (thanks to an external contributor! ref mozilla/rust-ece#47) so we can remove quite a bit of key parsing-and-re-serializing here.

let mut auth_secret = vec![0u8; 16];
let mut salt = vec![0u8; 16];
rc_crypto::rand::fill(&mut auth_secret).unwrap();
rc_crypto::rand::fill(&mut salt).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not letting you pass in this salt, was the main breaking API change. The latest version of rust-ece just makes one for you automatically.

@@ -178,260 +178,10 @@ pub(crate) fn init() {
#[cfg(test)]
mod tests {
use super::*;
use ece::*;

// Copy-pasta from the tests in the ECE crate.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty happy to dump this copy-pasta...

@rfk rfk marked this pull request as ready for review March 22, 2021 02:41
@rfk rfk force-pushed the ece-interface-cleanups branch from a073394 to bc9567d Compare March 22, 2021 02:41
@rfk rfk requested a review from lougeniaC64 March 22, 2021 02:41
@@ -188,7 +184,6 @@ impl Cryptography for Crypto {
}
}

// IIUC: objects created on one side of FFI can't be freed on the other side, so we have to use references (or clone)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to map what this comment is saying to anything happening in the code below it, so I presumptuously deleted it.

The rust-ece crate has had its interface simplified to remove footguns,
let's update to that release and get a few cleanups of our own while
we're at it.
@rfk rfk force-pushed the ece-interface-cleanups branch from 01568ec to d4457b2 Compare March 22, 2021 04:20
Copy link
Contributor

@lougeniaC64 lougeniaC64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

@rfk rfk merged commit ffa7a06 into main Mar 22, 2021
@rfk rfk deleted the ece-interface-cleanups branch March 22, 2021 22:04
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