@@ -44,7 +44,7 @@ use alloc::sync::Arc;
4444use  rustls:: crypto:: { 
4545    CipherSuiteCommon ,  CryptoProvider ,  GetRandomFailed ,  KeyProvider ,  SecureRandom , 
4646} ; 
47- use  rustls:: { crypto ,   CipherSuite ,  SupportedCipherSuite ,  Tls13CipherSuite } ; 
47+ use  rustls:: { CipherSuite ,  SupportedCipherSuite ,  Tls13CipherSuite } ; 
4848
4949#[ cfg( feature = "tls12" ) ]  
5050use  rustls:: SignatureScheme ; 
@@ -55,7 +55,7 @@ pub struct Provider;
5555pub  fn  provider ( )  -> CryptoProvider  { 
5656    CryptoProvider  { 
5757        cipher_suites :  ALL_CIPHER_SUITES . to_vec ( ) , 
58-         kx_groups :  ALL_KX_GROUPS . to_vec ( ) , 
58+         kx_groups :  kx :: ALL_KX_GROUPS . to_vec ( ) , 
5959        signature_verification_algorithms :  verify:: ALGORITHMS , 
6060        secure_random :  & Provider , 
6161        key_provider :  & Provider , 
@@ -81,14 +81,16 @@ impl KeyProvider for Provider {
8181} 
8282
8383#[ cfg( feature = "tls12" ) ]  
84- const  TLS12_ECDSA_SCHEMES :  [ SignatureScheme ;  4 ]  = [ 
84+ const  TLS12_ECDSA_SCHEMES :  & [ SignatureScheme ]  = & [ 
85+     #[ cfg( feature = "p256" ) ]  
8586    SignatureScheme :: ECDSA_NISTP256_SHA256 , 
87+     #[ cfg( feature = "p384" ) ]  
8688    SignatureScheme :: ECDSA_NISTP384_SHA384 , 
87-     SignatureScheme :: ECDSA_NISTP521_SHA512 , 
89+     # [ cfg ( feature =  "ed25519" ) ] 
8890    SignatureScheme :: ED25519 , 
8991] ; 
9092
91- #[ cfg( feature = "tls12" ) ]  
93+ #[ cfg( all ( feature = "tls12" ,  feature =  "rsa" ) ) ]  
9294const  TLS12_RSA_SCHEMES :  [ SignatureScheme ;  6 ]  = [ 
9395    SignatureScheme :: RSA_PKCS1_SHA256 , 
9496    SignatureScheme :: RSA_PKCS1_SHA384 , 
@@ -98,7 +100,7 @@ const TLS12_RSA_SCHEMES: [SignatureScheme; 6] = [
98100    SignatureScheme :: RSA_PSS_SHA512 , 
99101] ; 
100102
101- #[ cfg( feature = "tls12" ) ]  
103+ #[ cfg( all ( feature = "tls12" ,  feature =  "aes-gcm" ) ) ]  
102104pub  const  TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 :  SupportedCipherSuite  =
103105    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
104106        common :  CipherSuiteCommon  { 
@@ -107,12 +109,12 @@ pub const TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
107109            confidentiality_limit :  u64:: MAX , 
108110        } , 
109111        kx :  rustls:: crypto:: KeyExchangeAlgorithm :: ECDHE , 
110-         sign :  & TLS12_ECDSA_SCHEMES , 
112+         sign :  TLS12_ECDSA_SCHEMES , 
111113        aead_alg :  & aead:: gcm:: Tls12Aes128Gcm , 
112114        prf_provider :  & rustls:: crypto:: tls12:: PrfUsingHmac ( hmac:: SHA256 ) , 
113115    } ) ; 
114116
115- #[ cfg( feature = "tls12" ) ]  
117+ #[ cfg( all ( feature = "tls12" ,  feature =  "aes-gcm" ) ) ]  
116118pub  const  TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 :  SupportedCipherSuite  =
117119    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
118120        common :  CipherSuiteCommon  { 
@@ -121,12 +123,12 @@ pub const TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
121123            confidentiality_limit :  u64:: MAX , 
122124        } , 
123125        kx :  rustls:: crypto:: KeyExchangeAlgorithm :: ECDHE , 
124-         sign :  & TLS12_ECDSA_SCHEMES , 
126+         sign :  TLS12_ECDSA_SCHEMES , 
125127        prf_provider :  & rustls:: crypto:: tls12:: PrfUsingHmac ( hmac:: SHA384 ) , 
126128        aead_alg :  & aead:: gcm:: Tls12Aes256Gcm , 
127129    } ) ; 
128130
129- #[ cfg( feature = "tls12" ) ]  
131+ #[ cfg( all ( feature = "tls12" ,  feature =  "chacha20poly1305" ) ) ]  
130132pub  const  TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 :  SupportedCipherSuite  =
131133    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
132134        common :  CipherSuiteCommon  { 
@@ -136,18 +138,12 @@ pub const TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
136138        } , 
137139        prf_provider :  & rustls:: crypto:: tls12:: PrfUsingHmac ( hmac:: SHA256 ) , 
138140        kx :  rustls:: crypto:: KeyExchangeAlgorithm :: ECDHE , 
139-         sign :  & TLS12_ECDSA_SCHEMES , 
141+         sign :  TLS12_ECDSA_SCHEMES , 
140142        aead_alg :  & aead:: chacha20:: Chacha20Poly1305 , 
141143    } ) ; 
142144
143- #[ cfg( feature = "tls12" ) ]  
144- const  TLS_ECDHE_ECDSA_SUITES :  & [ SupportedCipherSuite ]  = & [ 
145-     TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 , 
146-     TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 , 
147-     TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 , 
148- ] ; 
149145
150- #[ cfg( feature = "tls12" ) ]  
146+ #[ cfg( all ( feature = "tls12" ,  feature =  "aes-gcm" ,  feature =  "rsa" ) ) ]  
151147pub  const  TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 :  SupportedCipherSuite  =
152148    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
153149        common :  CipherSuiteCommon  { 
@@ -161,7 +157,7 @@ pub const TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
161157        prf_provider :  & rustls:: crypto:: tls12:: PrfUsingHmac ( hmac:: SHA256 ) , 
162158    } ) ; 
163159
164- #[ cfg( feature = "tls12" ) ]  
160+ #[ cfg( all ( feature = "tls12" ,  feature =  "aes-gcm" ,  feature =  "ecdsa" ,  feature =  "rsa" ) ) ]  
165161pub  const  TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 :  SupportedCipherSuite  =
166162    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
167163        common :  CipherSuiteCommon  { 
@@ -175,7 +171,7 @@ pub const TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
175171        aead_alg :  & aead:: gcm:: Tls12Aes256Gcm , 
176172    } ) ; 
177173
178- #[ cfg( feature = "tls12" ) ]  
174+ #[ cfg( all ( feature = "tls12" ,  feature =  "rsa" ,  feature =  "chacha20poly1305" ) ) ]  
179175pub  const  TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 :  SupportedCipherSuite  =
180176    SupportedCipherSuite :: Tls12 ( & rustls:: Tls12CipherSuite  { 
181177        common :  CipherSuiteCommon  { 
@@ -189,23 +185,26 @@ pub const TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
189185        aead_alg :  & aead:: chacha20:: Chacha20Poly1305 , 
190186    } ) ; 
191187
192- #[ cfg( feature = "tls12" ) ]  
193- const  TLS_ECDHE_RSA_SUITES :  & [ SupportedCipherSuite ]  = & [ 
188+ #[ cfg( all( feature = "tls12" ,  feature = "ecdsa" ) ) ]  
189+ const  TLS12_SUITES :  & [ SupportedCipherSuite ]  = & [ 
190+     #[ cfg( feature = "aes-gcm" ) ]  
191+     TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 , 
192+     #[ cfg( feature = "aes-gcm" ) ]  
193+     TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 , 
194+     #[ cfg( feature = "chacha20poly1305" ) ]  
195+     TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 , 
196+     #[ cfg( all( feature = "rsa" ,  feature = "aes-gcm" ) ) ]  
194197    TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 , 
198+     #[ cfg( all( feature = "rsa" ,  feature = "aes-gcm" ) ) ]  
195199    TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 , 
200+     #[ cfg( all( feature = "rsa" ,  feature = "chacha20poly1305" ) ) ]  
196201    TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 , 
197202] ; 
198203
199- #[ cfg( feature = "tls12" ) ]  
200- const  TLS12_SUITES :  & [ SupportedCipherSuite ]  = misc:: const_concat_slices!( 
201-     SupportedCipherSuite , 
202-     TLS_ECDHE_ECDSA_SUITES , 
203-     TLS_ECDHE_RSA_SUITES 
204- ) ; 
205- 
206204#[ cfg( not( feature = "tls12" ) ) ]  
207205const  TLS12_SUITES :  & [ SupportedCipherSuite ]  = & [ ] ; 
208206
207+ #[ cfg( feature = "aes-gcm" ) ]  
209208pub  const  TLS13_AES_128_GCM_SHA256 :  SupportedCipherSuite  =
210209    SupportedCipherSuite :: Tls13 ( & Tls13CipherSuite  { 
211210        common :  CipherSuiteCommon  { 
@@ -218,6 +217,7 @@ pub const TLS13_AES_128_GCM_SHA256: SupportedCipherSuite =
218217        quic :  None , 
219218    } ) ; 
220219
220+ #[ cfg( feature = "aes-gcm" ) ]  
221221pub  const  TLS13_AES_256_GCM_SHA384 :  SupportedCipherSuite  =
222222    SupportedCipherSuite :: Tls13 ( & Tls13CipherSuite  { 
223223        common :  CipherSuiteCommon  { 
@@ -230,9 +230,7 @@ pub const TLS13_AES_256_GCM_SHA384: SupportedCipherSuite =
230230        quic :  None , 
231231    } ) ; 
232232
233- const  TLS13_AES_SUITES :  & [ SupportedCipherSuite ]  =
234-     & [ TLS13_AES_128_GCM_SHA256 ,  TLS13_AES_256_GCM_SHA384 ] ; 
235- 
233+ #[ cfg( feature = "chacha20poly1305" ) ]  
236234pub  const  TLS13_CHACHA20_POLY1305_SHA256 :  SupportedCipherSuite  =
237235    SupportedCipherSuite :: Tls13 ( & Tls13CipherSuite  { 
238236        common :  CipherSuiteCommon  { 
@@ -245,11 +243,14 @@ pub const TLS13_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
245243        quic :  None , 
246244    } ) ; 
247245
248- const  TLS13_SUITES :  & [ SupportedCipherSuite ]  = misc:: const_concat_slices!( 
249-     SupportedCipherSuite , 
250-     TLS13_AES_SUITES , 
251-     & [ TLS13_CHACHA20_POLY1305_SHA256 ] 
252- ) ; 
246+ const  TLS13_SUITES :  & [ SupportedCipherSuite ]  = & [ 
247+         #[ cfg( feature = "aes-gcm" ) ]  
248+         TLS13_AES_128_GCM_SHA256 , 
249+         #[ cfg( feature = "aes-gcm" ) ]  
250+         TLS13_AES_256_GCM_SHA384 , 
251+         #[ cfg( feature = "chacha20poly1305" ) ]  
252+         TLS13_CHACHA20_POLY1305_SHA256 
253+ ] ; 
253254
254255static  ALL_CIPHER_SUITES :  & [ SupportedCipherSuite ]  = misc:: const_concat_slices!( 
255256    SupportedCipherSuite , 
@@ -272,22 +273,13 @@ pub use verify::eddsa::ED25519;
272273#[ cfg( feature = "rsa" ) ]  
273274pub  use  verify:: rsa:: { RSA_PKCS1_SHA256 ,  RSA_PKCS1_SHA384 ,  RSA_PKCS1_SHA512 ,  RSA_PSS_SHA256 ,  RSA_PSS_SHA384 ,  RSA_PSS_SHA512 } ; 
274275
275- const  ALL_KX_GROUPS :  & [ & dyn  crypto:: SupportedKxGroup ]  = & [ 
276-     #[ cfg( feature = "x25519" ) ]  
277-     & X25519 , 
278-     #[ cfg( feature = "p256" ) ]  
279-     & SecP256R1 , 
280-     #[ cfg( feature = "p384" ) ]  
281-     & SecP384R1 
282- ] ; 
283- 
284276mod  aead; 
285277mod  hash; 
286278mod  hmac; 
287279
288- #[ cfg( any( feature = "x25519" ,  feature = "p256" ,  feature = "p384" ) ) ]  
289280mod  kx; 
290281mod  misc; 
282+ #[ cfg( feature = "quic" ) ]  
291283pub  mod  quic; 
292284pub  mod  sign; 
293285mod  verify; 
0 commit comments