Skip to content

Commit 688321b

Browse files
authored
Add support for AWS Libcrypto (AWS-LC) (pyca#12681)
* Add support for AWS-LC * Add GitHub CI Integration * Fix flake * Remove some untested functions since we don't support DH fully at the moment * Bindgen on Ubuntu 22.04 should work fine now * Feedback: Update Cargo.toml directly * Feeback: multi-line C comments, fixed similar spot * Combine logic * Feedback: HMAC hash check * cleanup * Indentation correction * Update aws-lc CI testing to use v1.49.0 tag * Rebased
1 parent 5161fb2 commit 688321b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+389
-138
lines changed

.github/bin/build_openssl.sh

+10
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,14 @@ elif [[ "${TYPE}" == "boringssl" ]]; then
6161
rm -rf "${OSSL_PATH}/bin"
6262
popd
6363
rm -rf boringssl/
64+
elif [[ "${TYPE}" == "aws-lc" ]]; then
65+
git clone https://github.com/aws/aws-lc.git
66+
pushd aws-lc
67+
git checkout "${VERSION}"
68+
cmake -B build -DCMAKE_INSTALL_PREFIX="${OSSL_PATH}"
69+
make -C build -j"$(nproc)" install
70+
# delete binaries we don't need
71+
rm -rf "${OSSL_PATH:?}/bin"
72+
popd # aws-lc
73+
rm -rf aws-lc/
6474
fi

.github/workflows/ci.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ jobs:
4747
- {VERSION: "3.12", NOXSESSION: "tests-randomorder"}
4848
# Latest commit on the BoringSSL main branch, as of Apr 16, 2025.
4949
- {VERSION: "3.12", NOXSESSION: "rust,tests", OPENSSL: {TYPE: "boringssl", VERSION: "23018360710de333b3343e63cbb3bd2dceb3287d"}}
50+
# Latest tag of AWS-LC main branch, as of March 28, 2025.
51+
- {VERSION: "3.12", NOXSESSION: "rust,tests", OPENSSL: {TYPE: "aws-lc", VERSION: "v1.49.0"}}
5052
# Latest commit on the OpenSSL master branch, as of Apr 16, 2025.
5153
- {VERSION: "3.12", NOXSESSION: "tests", OPENSSL: {TYPE: "openssl", VERSION: "24bc185439a950dc4427be10ec60231a923840ad"}}
5254
# Builds with various Rust versions. Includes MSRV and next
@@ -121,7 +123,7 @@ jobs:
121123
echo "RUSTFLAGS=-Clink-arg=-Wl,-rpath=${OSSL_PATH}/lib -Clink-arg=-Wl,-rpath=${OSSL_PATH}/lib64" >> $GITHUB_ENV
122124
if: matrix.PYTHON.OPENSSL
123125
- run: sudo apt-get install -y bindgen
124-
if: matrix.PYTHON.OPENSSL.TYPE == 'boringssl'
126+
if: matrix.PYTHON.OPENSSL.TYPE == 'boringssl' || matrix.PYTHON.OPENSSL.TYPE == 'aws-lc'
125127
- name: Cache rust and pip
126128
uses: ./.github/actions/cache
127129
timeout-minutes: 2

src/_cffi_src/openssl/bignum.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"""
3636

3737
CUSTOMIZATIONS = """
38-
#if CRYPTOGRAPHY_IS_BORINGSSL
38+
#if CRYPTOGRAPHY_IS_BORINGSSL || CRYPTOGRAPHY_IS_AWSLC
3939
static const long Cryptography_HAS_PRIME_CHECKS = 0;
4040
int (*BN_prime_checks_for_size)(int) = NULL;
4141
#else

src/_cffi_src/openssl/bio.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"""
3636

3737
CUSTOMIZATIONS = """
38-
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL
38+
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL \
39+
|| CRYPTOGRAPHY_IS_AWSLC
3940
4041
#if !defined(_WIN32)
4142
#include <sys/socket.h>

src/_cffi_src/openssl/cryptography.py

+7
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
#define CRYPTOGRAPHY_IS_BORINGSSL 0
4343
#endif
4444
45+
#if defined(OPENSSL_IS_AWSLC)
46+
#define CRYPTOGRAPHY_IS_AWSLC 1
47+
#else
48+
#define CRYPTOGRAPHY_IS_AWSLC 0
49+
#endif
50+
51+
4552
#if OPENSSL_VERSION_NUMBER < 0x10101050
4653
#error "pyca/cryptography MUST be linked with Openssl 1.1.1e or later"
4754
#endif

src/_cffi_src/openssl/engine.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
int ENGINE_free(ENGINE *);
2929
const char *ENGINE_get_name(const ENGINE *);
3030
31-
// These bindings are unused by cryptography or pyOpenSSL but are present
32-
// for advanced users who need them.
31+
/*
32+
These bindings are unused by cryptography or pyOpenSSL but are present
33+
for advanced users who need them.
34+
*/
3335
int ENGINE_ctrl_cmd_string(ENGINE *, const char *, const char *, int);
3436
void ENGINE_load_builtin_engines(void);
3537
EVP_PKEY *ENGINE_load_private_key(ENGINE *, const char *, UI_METHOD *, void *);
@@ -40,12 +42,16 @@
4042
#ifdef OPENSSL_NO_ENGINE
4143
static const long Cryptography_HAS_ENGINE = 0;
4244
43-
#if CRYPTOGRAPHY_IS_BORINGSSL
45+
#if CRYPTOGRAPHY_IS_BORINGSSL || CRYPTOGRAPHY_IS_AWSLC
4446
typedef void UI_METHOD;
4547
#endif
4648
47-
/* Despite being OPENSSL_NO_ENGINE, BoringSSL/LibreSSL define these symbols. */
48-
#if !CRYPTOGRAPHY_IS_BORINGSSL && !CRYPTOGRAPHY_IS_LIBRESSL
49+
/*
50+
Despite being OPENSSL_NO_ENGINE,
51+
BoringSSL/LibreSSL/AWS-LC define these symbols.
52+
*/
53+
#if !CRYPTOGRAPHY_IS_BORINGSSL && !CRYPTOGRAPHY_IS_LIBRESSL \
54+
&& !CRYPTOGRAPHY_IS_AWSLC
4955
int (*ENGINE_free)(ENGINE *) = NULL;
5056
void (*ENGINE_load_builtin_engines)(void) = NULL;
5157
#endif

src/_cffi_src/openssl/err.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"""
3737

3838
CUSTOMIZATIONS = """
39-
#if CRYPTOGRAPHY_IS_BORINGSSL
39+
#if CRYPTOGRAPHY_IS_BORINGSSL || CRYPTOGRAPHY_IS_AWSLC
4040
static const int EVP_F_EVP_ENCRYPTFINAL_EX = 0;
4141
static const int EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH = 0;
4242
#endif

src/_cffi_src/openssl/ssl.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
static const long Cryptography_HAS_SSL_ST;
1313
static const long Cryptography_HAS_TLS_ST;
1414
static const long Cryptography_HAS_TLSv1_3_FUNCTIONS;
15+
static const long Cryptography_HAS_TLSv1_3_HS_FUNCTIONS;
1516
static const long Cryptography_HAS_SIGALGS;
1617
static const long Cryptography_HAS_PSK;
1718
static const long Cryptography_HAS_PSK_TLSv1_3;
@@ -477,7 +478,8 @@
477478
478479
/* in OpenSSL 1.1.0 the SSL_ST values were renamed to TLS_ST and several were
479480
removed */
480-
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL
481+
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL \
482+
|| CRYPTOGRAPHY_IS_AWSLC
481483
static const long Cryptography_HAS_SSL_ST = 1;
482484
#else
483485
static const long Cryptography_HAS_SSL_ST = 0;
@@ -494,7 +496,8 @@
494496
static const long TLS_ST_OK = 0;
495497
#endif
496498
497-
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL
499+
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL \
500+
|| CRYPTOGRAPHY_IS_AWSLC
498501
static const long Cryptography_HAS_DTLS_GET_DATA_MTU = 0;
499502
size_t (*DTLS_get_data_mtu)(SSL *) = NULL;
500503
#else
@@ -589,9 +592,15 @@
589592
590593
#if CRYPTOGRAPHY_IS_BORINGSSL
591594
static const long Cryptography_HAS_TLSv1_3_FUNCTIONS = 0;
595+
int (*SSL_CTX_set_ciphersuites)(SSL_CTX *, const char *) = NULL;
596+
#else
597+
static const long Cryptography_HAS_TLSv1_3_FUNCTIONS = 1;
598+
#endif
592599
600+
#if CRYPTOGRAPHY_IS_BORINGSSL || CRYPTOGRAPHY_IS_AWSLC
601+
static const long Cryptography_HAS_TLSv1_3_HS_FUNCTIONS = 0;
593602
static const long SSL_VERIFY_POST_HANDSHAKE = 0;
594-
int (*SSL_CTX_set_ciphersuites)(SSL_CTX *, const char *) = NULL;
603+
595604
int (*SSL_verify_client_post_handshake)(SSL *) = NULL;
596605
void (*SSL_CTX_set_post_handshake_auth)(SSL_CTX *, int) = NULL;
597606
void (*SSL_set_post_handshake_auth)(SSL *, int) = NULL;
@@ -600,10 +609,10 @@
600609
int (*SSL_read_early_data)(SSL *, void *, size_t, size_t *) = NULL;
601610
int (*SSL_CTX_set_max_early_data)(SSL_CTX *, uint32_t) = NULL;
602611
#else
603-
static const long Cryptography_HAS_TLSv1_3_FUNCTIONS = 1;
612+
static const long Cryptography_HAS_TLSv1_3_HS_FUNCTIONS = 1;
604613
#endif
605614
606-
#if CRYPTOGRAPHY_IS_BORINGSSL
615+
#if CRYPTOGRAPHY_IS_BORINGSSL || CRYPTOGRAPHY_IS_AWSLC
607616
static const long Cryptography_HAS_SSL_COOKIE = 0;
608617
609618
static const long SSL_OP_COOKIE_EXCHANGE = 0;
@@ -623,7 +632,8 @@
623632
#else
624633
static const long Cryptography_HAS_SSL_COOKIE = 1;
625634
#endif
626-
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL
635+
#if CRYPTOGRAPHY_IS_LIBRESSL || CRYPTOGRAPHY_IS_BORINGSSL \
636+
|| CRYPTOGRAPHY_IS_AWSLC
627637
static const long Cryptography_HAS_PSK_TLSv1_3 = 0;
628638
void (*SSL_CTX_set_psk_find_session_callback)(SSL_CTX *,
629639
int (*)(
@@ -646,7 +656,7 @@
646656
int (*SSL_SESSION_set1_master_key)(SSL_SESSION *, const unsigned char *,
647657
size_t) = NULL;
648658
int (*SSL_SESSION_set_cipher)(SSL_SESSION *, const SSL_CIPHER *) = NULL;
649-
#if !CRYPTOGRAPHY_IS_BORINGSSL
659+
#if !CRYPTOGRAPHY_IS_BORINGSSL && !CRYPTOGRAPHY_IS_AWSLC
650660
int (*SSL_SESSION_set_protocol_version)(SSL_SESSION *, int) = NULL;
651661
#endif
652662
SSL_SESSION *(*Cryptography_SSL_SESSION_new)(void) = NULL;

src/cryptography/hazmat/backends/openssl/backend.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,19 @@ def hmac_supported(self, algorithm: hashes.HashAlgorithm) -> bool:
132132
# FIPS mode still allows SHA1 for HMAC
133133
if self._fips_enabled and isinstance(algorithm, hashes.SHA1):
134134
return True
135-
135+
if rust_openssl.CRYPTOGRAPHY_IS_AWSLC:
136+
return isinstance(
137+
algorithm,
138+
(
139+
hashes.SHA1,
140+
hashes.SHA224,
141+
hashes.SHA256,
142+
hashes.SHA384,
143+
hashes.SHA512,
144+
hashes.SHA512_224,
145+
hashes.SHA512_256,
146+
),
147+
)
136148
return self.hash_supported(algorithm)
137149

138150
def cipher_supported(self, cipher: CipherAlgorithm, mode: Mode) -> bool:
@@ -236,7 +248,10 @@ def elliptic_curve_exchange_algorithm_supported(
236248
)
237249

238250
def dh_supported(self) -> bool:
239-
return not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
251+
return (
252+
not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
253+
and not rust_openssl.CRYPTOGRAPHY_IS_AWSLC
254+
)
240255

241256
def dh_x942_serialization_supported(self) -> bool:
242257
return self._lib.Cryptography_HAS_EVP_PKEY_DHX == 1
@@ -252,6 +267,7 @@ def x448_supported(self) -> bool:
252267
return (
253268
not rust_openssl.CRYPTOGRAPHY_IS_LIBRESSL
254269
and not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
270+
and not rust_openssl.CRYPTOGRAPHY_IS_AWSLC
255271
)
256272

257273
def ed25519_supported(self) -> bool:
@@ -265,6 +281,7 @@ def ed448_supported(self) -> bool:
265281
return (
266282
not rust_openssl.CRYPTOGRAPHY_IS_LIBRESSL
267283
and not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
284+
and not rust_openssl.CRYPTOGRAPHY_IS_AWSLC
268285
)
269286

270287
def ecdsa_deterministic_supported(self) -> bool:
@@ -279,7 +296,10 @@ def poly1305_supported(self) -> bool:
279296
return True
280297

281298
def pkcs7_supported(self) -> bool:
282-
return not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
299+
return (
300+
not rust_openssl.CRYPTOGRAPHY_IS_BORINGSSL
301+
and not rust_openssl.CRYPTOGRAPHY_IS_AWSLC
302+
)
283303

284304

285305
backend = Backend()

src/cryptography/hazmat/bindings/_rust/openssl/__init__.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ __all__ = [
4747

4848
CRYPTOGRAPHY_IS_LIBRESSL: bool
4949
CRYPTOGRAPHY_IS_BORINGSSL: bool
50+
CRYPTOGRAPHY_IS_AWSLC: bool
5051
CRYPTOGRAPHY_OPENSSL_300_OR_GREATER: bool
5152
CRYPTOGRAPHY_OPENSSL_309_OR_GREATER: bool
5253
CRYPTOGRAPHY_OPENSSL_320_OR_GREATER: bool

src/cryptography/hazmat/bindings/openssl/_conditional.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,13 @@ def cryptography_has_custom_ext() -> list[str]:
6464

6565
def cryptography_has_tlsv13_functions() -> list[str]:
6666
return [
67-
"SSL_VERIFY_POST_HANDSHAKE",
6867
"SSL_CTX_set_ciphersuites",
68+
]
69+
70+
71+
def cryptography_has_tlsv13_hs_functions() -> list[str]:
72+
return [
73+
"SSL_VERIFY_POST_HANDSHAKE",
6974
"SSL_verify_client_post_handshake",
7075
"SSL_CTX_set_post_handshake_auth",
7176
"SSL_set_post_handshake_auth",
@@ -164,6 +169,9 @@ def cryptography_has_get_extms_support() -> list[str]:
164169
"Cryptography_HAS_PSK_TLSv1_3": cryptography_has_psk_tlsv13,
165170
"Cryptography_HAS_CUSTOM_EXT": cryptography_has_custom_ext,
166171
"Cryptography_HAS_TLSv1_3_FUNCTIONS": cryptography_has_tlsv13_functions,
172+
"Cryptography_HAS_TLSv1_3_HS_FUNCTIONS": (
173+
cryptography_has_tlsv13_hs_functions
174+
),
167175
"Cryptography_HAS_ENGINE": cryptography_has_engine,
168176
"Cryptography_HAS_VERIFIED_CHAIN": cryptography_has_verified_chain,
169177
"Cryptography_HAS_SRTP": cryptography_has_srtp,

src/rust/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ name = "cryptography_rust"
3333
crate-type = ["cdylib"]
3434

3535
[lints.rust]
36-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_309_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_320_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_330_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_350_OR_GREATER)', 'cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)', 'cfg(CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY)', 'cfg(CRYPTOGRAPHY_OSSLCONF, values("OPENSSL_NO_IDEA", "OPENSSL_NO_CAST", "OPENSSL_NO_BF", "OPENSSL_NO_CAMELLIA", "OPENSSL_NO_SEED", "OPENSSL_NO_SM4", "OPENSSL_NO_RC4"))'] }
36+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_309_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_320_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_330_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_350_OR_GREATER)', 'cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)', 'cfg(CRYPTOGRAPHY_IS_AWSLC)', 'cfg(CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY)', 'cfg(CRYPTOGRAPHY_OSSLCONF, values("OPENSSL_NO_IDEA", "OPENSSL_NO_CAST", "OPENSSL_NO_BF", "OPENSSL_NO_CAMELLIA", "OPENSSL_NO_SEED", "OPENSSL_NO_SM4", "OPENSSL_NO_RC4"))'] }

src/rust/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ fn main() {
3434
println!("cargo:rustc-cfg=CRYPTOGRAPHY_IS_BORINGSSL");
3535
}
3636

37+
if env::var("DEP_OPENSSL_AWSLC").is_ok() {
38+
println!("cargo:rustc-cfg=CRYPTOGRAPHY_IS_AWSLC");
39+
}
40+
3741
if env::var("CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY").map_or(false, |v| !v.is_empty() && v != "0")
3842
{
3943
println!("cargo:rustc-cfg=CRYPTOGRAPHY_BUILD_OPENSSL_NO_LEGACY");

src/rust/cryptography-key-parsing/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ cryptography-crypto = { path = "../cryptography-crypto" }
1515
cryptography-x509 = { path = "../cryptography-x509" }
1616

1717
[lints.rust]
18-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)', 'cfg(CRYPTOGRAPHY_OSSLCONF, values("OPENSSL_NO_RC2"))'] }
18+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)', 'cfg(CRYPTOGRAPHY_OSSLCONF, values("OPENSSL_NO_RC2"))', 'cfg(CRYPTOGRAPHY_IS_AWSLC)'] }

src/rust/cryptography-key-parsing/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ fn main() {
1313
println!("cargo:rustc-cfg=CRYPTOGRAPHY_IS_BORINGSSL");
1414
}
1515

16+
if env::var("DEP_OPENSSL_AWSLC").is_ok() {
17+
println!("cargo:rustc-cfg=CRYPTOGRAPHY_IS_AWSLC");
18+
}
19+
1620
if let Ok(vars) = env::var("DEP_OPENSSL_CONF") {
1721
for var in vars.split(',') {
1822
println!("cargo:rustc-cfg=CRYPTOGRAPHY_OSSLCONF=\"{var}\"");

src/rust/cryptography-key-parsing/src/ec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ pub(crate) fn ec_params_to_group(
4444
&cryptography_x509::oid::EC_SECT409K1 => openssl::nid::Nid::SECT409K1,
4545
&cryptography_x509::oid::EC_SECT571K1 => openssl::nid::Nid::SECT571K1,
4646

47-
#[cfg(not(CRYPTOGRAPHY_IS_BORINGSSL))]
47+
#[cfg(not(any(CRYPTOGRAPHY_IS_BORINGSSL, CRYPTOGRAPHY_IS_AWSLC)))]
4848
&cryptography_x509::oid::EC_BRAINPOOLP256R1 => openssl::nid::Nid::BRAINPOOL_P256R1,
49-
#[cfg(not(CRYPTOGRAPHY_IS_BORINGSSL))]
49+
#[cfg(not(any(CRYPTOGRAPHY_IS_BORINGSSL, CRYPTOGRAPHY_IS_AWSLC)))]
5050
&cryptography_x509::oid::EC_BRAINPOOLP384R1 => openssl::nid::Nid::BRAINPOOL_P384R1,
51-
#[cfg(not(CRYPTOGRAPHY_IS_BORINGSSL))]
51+
#[cfg(not(any(CRYPTOGRAPHY_IS_BORINGSSL, CRYPTOGRAPHY_IS_AWSLC)))]
5252
&cryptography_x509::oid::EC_BRAINPOOLP512R1 => openssl::nid::Nid::BRAINPOOL_P512R1,
5353

5454
_ => return Err(KeyParsingError::UnsupportedEllipticCurve(curve_oid.clone())),

src/rust/cryptography-key-parsing/src/pkcs8.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ pub fn parse_private_key(
8484
openssl::pkey::Id::X25519,
8585
)?)
8686
}
87-
#[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))]
87+
#[cfg(not(any(
88+
CRYPTOGRAPHY_IS_LIBRESSL,
89+
CRYPTOGRAPHY_IS_BORINGSSL,
90+
CRYPTOGRAPHY_IS_AWSLC
91+
)))]
8892
AlgorithmParameters::X448 => {
8993
let key_bytes = asn1::parse_single(k.private_key)?;
9094
Ok(openssl::pkey::PKey::private_key_from_raw_bytes(
@@ -99,7 +103,11 @@ pub fn parse_private_key(
99103
openssl::pkey::Id::ED25519,
100104
)?)
101105
}
102-
#[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))]
106+
#[cfg(not(any(
107+
CRYPTOGRAPHY_IS_LIBRESSL,
108+
CRYPTOGRAPHY_IS_BORINGSSL,
109+
CRYPTOGRAPHY_IS_AWSLC
110+
)))]
103111
AlgorithmParameters::Ed448 => {
104112
let key_bytes = asn1::parse_single(k.private_key)?;
105113
Ok(openssl::pkey::PKey::private_key_from_raw_bytes(

src/rust/cryptography-key-parsing/src/spki.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ pub fn parse_public_key(
2929
openssl::pkey::Id::ED25519,
3030
)
3131
.map_err(|_| KeyParsingError::InvalidKey)?),
32-
#[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))]
32+
#[cfg(not(any(
33+
CRYPTOGRAPHY_IS_LIBRESSL,
34+
CRYPTOGRAPHY_IS_BORINGSSL,
35+
CRYPTOGRAPHY_IS_AWSLC
36+
)))]
3337
AlgorithmParameters::Ed448 => Ok(openssl::pkey::PKey::public_key_from_raw_bytes(
3438
k.subject_public_key.as_bytes(),
3539
openssl::pkey::Id::ED448,
@@ -40,7 +44,11 @@ pub fn parse_public_key(
4044
openssl::pkey::Id::X25519,
4145
)
4246
.map_err(|_| KeyParsingError::InvalidKey)?),
43-
#[cfg(all(not(CRYPTOGRAPHY_IS_LIBRESSL), not(CRYPTOGRAPHY_IS_BORINGSSL)))]
47+
#[cfg(not(any(
48+
CRYPTOGRAPHY_IS_LIBRESSL,
49+
CRYPTOGRAPHY_IS_BORINGSSL,
50+
CRYPTOGRAPHY_IS_AWSLC
51+
)))]
4452
AlgorithmParameters::X448 => Ok(openssl::pkey::PKey::public_key_from_raw_bytes(
4553
k.subject_public_key.as_bytes(),
4654
openssl::pkey::Id::X448,

src/rust/cryptography-openssl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ foreign-types = "0.3"
1414
foreign-types-shared = "0.1"
1515

1616
[lints.rust]
17-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_320_OR_GREATER)', 'cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)'] }
17+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(CRYPTOGRAPHY_OPENSSL_300_OR_GREATER)', 'cfg(CRYPTOGRAPHY_OPENSSL_320_OR_GREATER)', 'cfg(CRYPTOGRAPHY_IS_LIBRESSL)', 'cfg(CRYPTOGRAPHY_IS_BORINGSSL)', 'cfg(CRYPTOGRAPHY_IS_AWSLC)'] }

0 commit comments

Comments
 (0)