File: 1002_feature_fencing.patch

package info (click to toggle)
rust-rustls 0.23.35%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,460 kB
  • sloc: sh: 199; python: 181; makefile: 11
file content (252 lines) | stat: -rw-r--r-- 7,689 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
Description: fence tests by needed features
  * Running tests with feature "ring" but not "std"
    fails in call to `UnixTime::now()`
  * Running tests with feature "hashbrown" but not "std"
    fails to infer type
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2025-02-14
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/rustls/src/client/handy.rs
+++ b/rustls/src/client/handy.rs
@@ -267,6 +267,7 @@
     use crate::{DigitallySignedStruct, Error, SignatureScheme, sign};
 
     #[test]
+    #[cfg(feature = "std")]
     fn test_noclientsessionstorage_does_nothing() {
         let c = NoClientSessionStorage {};
         let name = ServerName::try_from("example.com").unwrap();
--- a/rustls/src/server/handy.rs
+++ b/rustls/src/server/handy.rs
@@ -24,7 +24,7 @@
     }
 }
 
-#[cfg(any(feature = "std", feature = "hashbrown"))]
+#[cfg(any(feature = "std", all(feature = "default", feature = "hashbrown")))]
 mod cache {
     use alloc::vec::Vec;
     use core::fmt::{Debug, Formatter};
@@ -144,7 +144,7 @@
     }
 }
 
-#[cfg(any(feature = "std", feature = "hashbrown"))]
+#[cfg(any(feature = "std", all(feature = "default", feature = "hashbrown")))]
 pub use cache::ServerSessionMemoryCache;
 
 /// Something which never produces tickets.
--- a/rustls/src/lib.rs
+++ b/rustls/src/lib.rs
@@ -637,7 +637,7 @@
     pub use builder::WantsServerCert;
     #[cfg(any(feature = "std", feature = "hashbrown"))]
     pub use handy::ResolvesServerCertUsingSni;
-    #[cfg(any(feature = "std", feature = "hashbrown"))]
+    #[cfg(any(feature = "std", all(feature = "default", feature = "hashbrown")))]
     pub use handy::ServerSessionMemoryCache;
     pub use handy::{AlwaysResolvesServerRawPublicKeys, NoServerSessionStorage};
     pub use server_conn::{
--- a/rustls/src/client/test.rs
+++ b/rustls/src/client/test.rs
@@ -5,7 +5,7 @@
 
 use pki_types::{CertificateDer, ServerName};
 
-use crate::client::{ClientConfig, ClientConnection, Resumption, Tls12Resumption};
+use crate::client::{ClientConfig, Resumption, Tls12Resumption};
 use crate::crypto::CryptoProvider;
 use crate::enums::{CipherSuite, ProtocolVersion, SignatureScheme};
 use crate::msgs::base::PayloadU16;
@@ -19,6 +19,9 @@
 use crate::sync::Arc;
 use crate::{Error, PeerIncompatible, PeerMisbehaved, RootCertStore};
 
+#[cfg(feature = "std")]
+use crate::client::ClientConnection;
+
 #[macro_rules_attribute::apply(test_for_each_provider)]
 mod tests {
     use std::sync::OnceLock;
@@ -45,6 +48,7 @@
 
     /// Tests that session_ticket(35) extension
     /// is not sent if the client does not support TLS 1.2.
+    #[cfg(feature = "std")]
     #[test]
     fn test_no_session_ticket_request_on_tls_1_3() {
         let mut config =
@@ -59,6 +63,7 @@
         assert!(ch.extensions.session_ticket.is_none());
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_no_renegotiation_scsv_on_tls_1_3() {
         let ch = client_hello_sent_for_config(
@@ -75,6 +80,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_does_not_offer_sha1() {
         for version in crate::ALL_VERSIONS {
@@ -96,6 +102,7 @@
         }
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_rejects_hrr_with_varied_session_id() {
         let config =
@@ -134,7 +141,7 @@
         );
     }
 
-    #[cfg(feature = "tls12")]
+    #[cfg(all(feature = "std", feature = "tls12"))]
     #[test]
     fn test_client_rejects_no_extended_master_secret_extension_when_require_ems_or_fips() {
         let mut config =
@@ -178,6 +185,7 @@
         );
     }
 
+    #[cfg(all(feature = "std", feature = "tls12"))]
     #[test]
     fn cas_extension_in_client_hello_if_server_verifier_requests_it() {
         let cas_sending_server_verifier =
@@ -206,7 +214,7 @@
     }
 
     /// Regression test for <https://github.com/seanmonstar/reqwest/issues/2191>
-    #[cfg(feature = "tls12")]
+    #[cfg(all(feature = "std", feature = "tls12"))]
     #[test]
     fn test_client_with_custom_verifier_can_accept_ecdsa_sha1_signatures() {
         let verifier = Arc::new(ExpectSha1EcdsaVerifier::default());
@@ -340,6 +348,7 @@
         }
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_requiring_rpk_rejects_server_that_only_offers_x509_id_by_omission() {
         assert_eq!(
@@ -348,6 +357,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_requiring_rpk_rejects_server_that_only_offers_x509_id() {
         assert_eq!(
@@ -359,6 +369,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_requiring_rpk_rejects_server_that_only_demands_x509_by_omission() {
         assert_eq!(
@@ -370,6 +381,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_requiring_rpk_rejects_server_that_only_demands_x509() {
         assert_eq!(
@@ -382,6 +394,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     #[test]
     fn test_client_requiring_rpk_accepts_rpk_server() {
         assert_eq!(
@@ -394,6 +407,7 @@
         );
     }
 
+    #[cfg(feature = "std")]
     fn client_requiring_rpk_receives_server_ee(
         encrypted_extensions: ServerExtensions<'_>,
     ) -> Result<(), Error> {
@@ -445,6 +459,7 @@
         conn.process_new_packets().map(|_| ())
     }
 
+    #[cfg(feature = "std")]
     fn client_config_for_rpk(key_log: Arc<dyn KeyLog>) -> ClientConfig {
         let mut config = ClientConfig::builder_with_provider(x25519_provider().into())
             .with_protocol_versions(&[&version::TLS13])
@@ -630,6 +645,7 @@
 #[cfg(all(
     feature = "aws-lc-rs",
     feature = "prefer-post-quantum",
+    feature = "std",
     not(feature = "fips")
 ))]
 #[test]
@@ -653,7 +669,7 @@
     assert_eq!(key_shares[1].group, NamedGroup::X25519);
 }
 
-#[cfg(feature = "aws-lc-rs")]
+#[cfg(all(feature = "aws-lc-rs", feature = "std"))]
 #[test]
 fn hybrid_kx_component_share_not_offered_unless_supported_separately() {
     use crate::crypto::aws_lc_rs;
@@ -679,6 +695,7 @@
     assert_eq!(key_shares[0].group, NamedGroup::X25519MLKEM768);
 }
 
+#[cfg(feature = "std")]
 fn client_hello_sent_for_config(config: ClientConfig) -> Result<ClientHelloPayload, Error> {
     let mut conn =
         ClientConnection::new(config.into(), ServerName::try_from("localhost").unwrap())?;
--- a/rustls/src/server/test.rs
+++ b/rustls/src/server/test.rs
@@ -63,6 +63,7 @@
 }
 
 #[macro_rules_attribute::apply(test_for_each_provider)]
+#[cfg(feature = "std")]
 mod tests {
     use super::super::*;
     use crate::common_state::KxState;
@@ -75,7 +76,10 @@
     use crate::server::{AlwaysResolvesServerRawPublicKeys, ServerConfig, ServerConnection};
     use crate::sign::CertifiedKey;
     use crate::sync::Arc;
-    use crate::{CipherSuiteCommon, SupportedCipherSuite, Tls12CipherSuite, version};
+    use crate::{CipherSuiteCommon, SupportedCipherSuite, version};
+
+    #[cfg(feature = "tls12")]
+    use crate::Tls12CipherSuite;
 
     #[cfg(feature = "tls12")]
     #[test]
@@ -280,6 +284,7 @@
         ]
     }
 
+    #[cfg(feature = "tls12")]
     fn ffdhe_provider() -> CryptoProvider {
         CryptoProvider {
             kx_groups: vec![FAKE_FFDHE_GROUP],
@@ -324,9 +329,11 @@
         }
     }
 
+    #[cfg(feature = "tls12")]
     static TLS_DHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
         SupportedCipherSuite::Tls12(&TLS12_DHE_RSA_WITH_AES_128_GCM_SHA256);
 
+    #[cfg(feature = "tls12")]
     static TLS12_DHE_RSA_WITH_AES_128_GCM_SHA256: Tls12CipherSuite =
         match &super::provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 {
             SupportedCipherSuite::Tls12(provider) => Tls12CipherSuite {