/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rcgen-0.14.2/src/ring_like.rs
Line | Count | Source |
1 | | #[cfg(all(feature = "crypto", feature = "aws_lc_rs"))] |
2 | | pub(crate) use aws_lc_rs::*; |
3 | | #[cfg(all(feature = "crypto", feature = "ring", not(feature = "aws_lc_rs")))] |
4 | | pub(crate) use ring::*; |
5 | | |
6 | | #[cfg(feature = "crypto")] |
7 | | use crate::error::ExternalError; |
8 | | #[cfg(feature = "crypto")] |
9 | | use crate::Error; |
10 | | |
11 | | #[cfg(feature = "crypto")] |
12 | 0 | pub(crate) fn ecdsa_from_pkcs8( |
13 | 0 | alg: &'static signature::EcdsaSigningAlgorithm, |
14 | 0 | pkcs8: &[u8], |
15 | 0 | _rng: &dyn rand::SecureRandom, |
16 | 0 | ) -> Result<signature::EcdsaKeyPair, Error> { |
17 | | #[cfg(all(feature = "ring", not(feature = "aws_lc_rs")))] |
18 | | { |
19 | | signature::EcdsaKeyPair::from_pkcs8(alg, pkcs8, _rng)._err() |
20 | | } |
21 | | |
22 | | #[cfg(feature = "aws_lc_rs")] |
23 | | { |
24 | 0 | signature::EcdsaKeyPair::from_pkcs8(alg, pkcs8)._err() |
25 | | } |
26 | 0 | } |
27 | | |
28 | | #[cfg(all(feature = "crypto", feature = "aws_lc_rs"))] |
29 | 0 | pub(crate) fn ecdsa_from_private_key_der( |
30 | 0 | alg: &'static signature::EcdsaSigningAlgorithm, |
31 | 0 | key: &[u8], |
32 | 0 | ) -> Result<signature::EcdsaKeyPair, Error> { |
33 | 0 | signature::EcdsaKeyPair::from_private_key_der(alg, key)._err() |
34 | 0 | } |
35 | | |
36 | | #[cfg(feature = "crypto")] |
37 | 0 | pub(crate) fn rsa_key_pair_public_modulus_len(kp: &signature::RsaKeyPair) -> usize { |
38 | | #[cfg(all(feature = "ring", not(feature = "aws_lc_rs")))] |
39 | | { |
40 | | kp.public().modulus_len() |
41 | | } |
42 | | |
43 | | #[cfg(feature = "aws_lc_rs")] |
44 | | { |
45 | 0 | kp.public_modulus_len() |
46 | | } |
47 | 0 | } |
48 | | |
49 | | #[cfg(all(feature = "crypto", not(any(feature = "ring", feature = "aws_lc_rs"))))] |
50 | | compile_error!("At least one of the 'ring' or 'aws_lc_rs' features must be activated when the 'crypto' feature is enabled"); |