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

Configurable cryptography #23

Merged
merged 9 commits into from
Apr 23, 2019
Merged

Conversation

thomcc
Copy link

@thomcc thomcc commented Apr 13, 2019

By default it has the use_ring feature enabled, and uses ring. Someone who wants to use openssl can turn on the use_openssl feature, and someone who wants neither (e.g. mozilla/application-services) can turn off both and provide a custom impl with set_cryptographer.

Since there's nothing sane we can do if both features are on, we detect it and give a explicit error message in a build.rs.

Annoyingly, this means testing / linting both requires

cargo test
cargo test --no-default-features --features 'use_openssl'

Cargo doesn't really support mutually exclusive features well.

Note: this needs the latest stable version of Rust to compile (e.g. the one that came out yesterday). I don't know if anything needs to change in the tc config for that to work.

Supports mozilla/application-services#959, assuming @eoger thinks we can shoehorn what we need into the trait I've defined there.

There's probably a way this could have less overhead in the ring/openssl cases, but it would be harder to test, so I didn't go with that. As it is, the dynamic machinery is used every time.

@thomcc thomcc requested a review from djmitche as a code owner April 13, 2019 02:16
@thomcc
Copy link
Author

thomcc commented Apr 13, 2019

Note: let's not land this before @eoger gets a chance to review.

@djmitche djmitche requested a review from eoger April 13, 2019 21:34
@djmitche
Copy link
Collaborator

Sure thing. I'd like to get the CI updated before we land, too.

@thomcc
Copy link
Author

thomcc commented Apr 13, 2019

Given the account that seems prudent :P.

I'll probably need a pointer on how to do that though, unless slapping in a rustup update is acceptable.

Copy link
Collaborator

@djmitche djmitche left a comment

Choose a reason for hiding this comment

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

Let's add a section to the README about this, perhaps "Upgrading", that notes the changes here (seems mostly just things now returning Result, but also Key::new no longer taking a reference).

I guess the "dynamic machinery" you indicate is dyn HmacKey etc., meaning that crypto operations involve a vtable call or two. That's sort of sad since it's in the hot path for this library, but it's a hot path that involves a bunch of crypto math so an indirect jump or two probably isn't a big deal.

Otherwise, I'm quite happy with this. I'll fix up the CI in another push, but don't let that slow you down.

src/crypto/holder.rs Show resolved Hide resolved
src/error.rs Show resolved Hide resolved
src/payload.rs Show resolved Hide resolved
src/payload.rs Show resolved Hide resolved
src/credentials.rs Show resolved Hide resolved
src/credentials.rs Show resolved Hide resolved
@djmitche djmitche self-requested a review April 16, 2019 21:20
- If you were passing e.g. `&hawk::SHA256`, you probably just need
to pass `hawk::SHA256` now instead.

- BREAKING (though unlikely): `Error::Rng` has been removed, and `Error::Crypto` added
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@eoger eoger left a comment

Choose a reason for hiding this comment

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

Crypto parts looks good to me, thanks a lot for taking on that work Thom

src/crypto/holder.rs Show resolved Hide resolved
@djmitche
Copy link
Collaborator

I'll get this merged, but I'd like #27 to get merged too before making a release, since otherwise that PR would constitute a further breaking change.

@djmitche djmitche merged commit bc867e4 into taskcluster:master Apr 23, 2019
@rfk
Copy link

rfk commented May 9, 2019

Hi @djmitche, anything else we can do to help with a new release to include this change?

@djmitche
Copy link
Collaborator

djmitche commented May 9, 2019

I think we can do that. I have another PR in the works to support signing http.request.Builder values, that is another breaking change, but there are after all a countably infinite set of possible values for the X in X.Y.Z :)

@djmitche
Copy link
Collaborator

djmitche commented May 9, 2019

v3.0.0 should be on crates.io shortly!

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.

None yet

4 participants