-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add aws_lc_rs support to use as crypto backend
- Loading branch information
1 parent
53a5232
commit b2860b2
Showing
10 changed files
with
518 additions
and
128 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,55 @@ | ||
#[cfg(feature = "ring")] | ||
pub use ring::*; | ||
|
||
#[cfg(feature = "aws_lc_rs")] | ||
pub use aws_lc_rs::*; | ||
|
||
use crate::{error::ExternalError, Error}; | ||
|
||
/// Constructs an ECDSA key pair by parsing an unencrypted PKCS#8 v1 | ||
/// id-ecPublicKey `ECPrivateKey` key. | ||
/// | ||
/// The input must be in PKCS#8 v1 format. It must contain the public key in | ||
/// the `ECPrivateKey` structure; `from_pkcs8()` will verify that the public | ||
/// key and the private key are consistent with each other. The algorithm | ||
/// identifier must identify the curve by name; it must not use an | ||
/// "explicit" encoding of the curve. The `parameters` field of the | ||
/// `ECPrivateKey`, if present, must be the same named curve that is in the | ||
/// algorithm identifier in the PKCS#8 header. | ||
pub fn ecdsa_from_pkcs8( | ||
alg: &'static signature::EcdsaSigningAlgorithm, | ||
pkcs8: &[u8], | ||
_rng: &dyn rand::SecureRandom, | ||
) -> Result<signature::EcdsaKeyPair, Error> { | ||
#[cfg(feature = "ring")] | ||
{ | ||
Ok(signature::EcdsaKeyPair::from_pkcs8(alg, pkcs8, _rng)._err()?) | ||
} | ||
|
||
#[cfg(feature = "aws_lc_rs")] | ||
{ | ||
Ok(signature::EcdsaKeyPair::from_pkcs8(alg, pkcs8)._err()?) | ||
} | ||
} | ||
|
||
/// The length, in bytes, of the public modulus. | ||
/// | ||
/// The modulus length is rounded up to a whole number of bytes if its | ||
/// bit length isn't a multiple of 8. | ||
pub fn rsa_key_pair_public_modulus_len(kp: &signature::RsaKeyPair) -> usize { | ||
#[cfg(feature = "ring")] | ||
{ | ||
kp.public().modulus_len() | ||
} | ||
|
||
#[cfg(feature = "aws_lc_rs")] | ||
{ | ||
kp.public_modulus_len() | ||
} | ||
} | ||
|
||
#[cfg(all(feature = "ring", feature = "aws_lc_rs"))] | ||
compile_error!("Only one feature among 'ring' and 'aws_lc_rs' can be active at the same time"); | ||
|
||
#[cfg(not(any(feature = "ring", feature = "aws_lc_rs")))] | ||
compile_error!("At least one of the features among 'ring' and 'aws_lc_rs' must be activated"); |
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