-
Notifications
You must be signed in to change notification settings - Fork 271
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
support ring and aws-lc-rs (default = ring) #402
Open
GlenDC
wants to merge
1
commit into
Keats:master
Choose a base branch
from
GlenDC:patch/389/aws-lc-rs-support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#[cfg(all(feature = "aws_lc_rs", not(any(target_arch = "wasm32", target_os = "windows"))))] | ||
pub(crate) mod dep { | ||
pub(crate) use ::aws_lc_rs::{constant_time, error, hmac, rand}; | ||
|
||
pub(crate) mod signature { | ||
pub(crate) use ::aws_lc_rs::signature::*; | ||
|
||
#[inline] | ||
pub(crate) fn ecdsa_key_pair_from_pkcs8( | ||
alg: &'static EcdsaSigningAlgorithm, | ||
pkcs8: &[u8], | ||
_rng: &dyn ::aws_lc_rs::rand::SecureRandom, | ||
) -> Result<EcdsaKeyPair, ::aws_lc_rs::error::KeyRejected> { | ||
EcdsaKeyPair::from_pkcs8(alg, pkcs8) | ||
} | ||
|
||
#[inline] | ||
pub(crate) fn rsa_key_pair_public_modulus_len(key_pair: &RsaKeyPair) -> usize { | ||
key_pair.public_modulus_len() | ||
} | ||
} | ||
} | ||
|
||
#[cfg(not(all(feature = "aws_lc_rs", not(any(target_arch = "wasm32", target_os = "windows")))))] | ||
pub(crate) mod dep { | ||
pub(crate) use ::ring::{constant_time, error, hmac, rand}; | ||
|
||
pub(crate) mod signature { | ||
pub(crate) use ::ring::signature::*; | ||
|
||
#[inline] | ||
pub(crate) fn ecdsa_key_pair_from_pkcs8( | ||
alg: &'static EcdsaSigningAlgorithm, | ||
pkcs8: &[u8], | ||
rng: &dyn ::ring::rand::SecureRandom, | ||
) -> Result<EcdsaKeyPair, ::ring::error::KeyRejected> { | ||
EcdsaKeyPair::from_pkcs8(alg, pkcs8, rng) | ||
} | ||
|
||
#[inline] | ||
pub(crate) fn rsa_key_pair_public_modulus_len(key_pair: &RsaKeyPair) -> usize { | ||
key_pair.public().modulus_len() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ring does have |
||
} | ||
} | ||
} | ||
|
||
pub(crate) use dep::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other functions used by
jsonwebtoken
have therng
param which is ignored. Sadly this one seems to be forgotten. We could also try to upstream this to aws-lc-rs, but would require a major release, not sure how eager they are for that :)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! -- I stumbled across this thread, and thought I would provide a little context around this difference.
In ring v0.16.x,
EcdsaKeyPair::from_pkcs8
only takes two parameters. But in ring 0.17, this function takes three parameters. Because aws-lc-rs v1.x maintains compatibility with ring 0.16.x, our function (likewise) only takes two parameters.Unfortunately, I don't see a way we could support a 3rd parameter w/o breaking backwards compatibility. But feel free to drop us an issue if you have questions or would like to suggest an improvement to our API. Thanks!