Skip to main content

crypto_profile_awslc3/
lib.rs

1//! The crypto-profile backend on the AWS-LC FIPS 3.x module (aws-lc-rs 1.17, `fips`).
2//! `rustls` is re-exported because its types are this crate's API; `aws-lc-rs` is not.
3#![deny(missing_docs)]
4
5pub use crypto_profile::*;
6#[cfg(feature = "test-support")]
7pub use rcgen;
8pub use rustls;
9
10crypto_profile::provider!(crate::provider_arms);
11mod provider_arms;
12
13crypto_profile::backend_body!(crate::backend_arms);
14mod backend_arms;
15#[cfg(any(test, feature = "test-support"))]
16pub use backend_body::test_support;
17pub use backend_body::{Resolved, assert_module_approves, resolve};
18pub use backend_body::{aead, csr, digest, fips, random, sealbox, signature, tls};
19
20/// The AWS-LC FIPS module (line and linkage) this build links. Its certificate status is
21/// [`fips::certificate()`]; for 3.x the certified release is 3.1.0.
22pub const MODULE: Module = Module {
23    line: ModuleLine::AwsLcFips3,
24    linkage: if cfg!(crypto_profile_static) {
25        Linkage::Static
26    } else {
27        Linkage::Dynamic
28    },
29};
30
31/// Returns the exact runtime-linked AWS-LC release, independently of its certificate release.
32///
33/// This initializes the linked library and also reflects its version with dynamic linkage.
34pub fn awslc_version() -> &'static str {
35    aws_lc_rs::awslc_version()
36}
37
38pub(crate) fn ensure(alg: Algorithm) -> Result<(), CryptoError> {
39    ensure_available(MODULE, alg)
40}
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn ensure_refuses_unavailable_keys_and_schemes() {
48        for algorithm in [
49            Algorithm::Signature(SignatureAlgorithm::MlDsa87),
50            Algorithm::Scheme(TlsSignatureScheme::MlDsa87),
51        ] {
52            assert_eq!(ensure(algorithm), Err(CryptoError::Unavailable(algorithm)));
53        }
54        assert_eq!(
55            ensure(Algorithm::Signature(SignatureAlgorithm::EcdsaP384Sha384)),
56            Ok(())
57        );
58    }
59}