-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrustls-patched-fix.patch
More file actions
220 lines (205 loc) · 9.07 KB
/
rustls-patched-fix.patch
File metadata and controls
220 lines (205 loc) · 9.07 KB
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
diff --git a/rustls/src/cipher.rs b/rustls/src/cipher.rs
index b4cde3b9..9cb5a50b 100644
--- a/rustls/src/cipher.rs
+++ b/rustls/src/cipher.rs
@@ -30,17 +30,17 @@ impl dyn MessageDecrypter {
/// A write or read IV.
#[derive(Default)]
-pub(crate) struct Iv(pub(crate) [u8; ring::aead::NONCE_LEN]);
+pub(crate) struct Iv(pub(crate) [u8; aead::NONCE_LEN]);
impl Iv {
#[cfg(feature = "tls12")]
- fn new(value: [u8; ring::aead::NONCE_LEN]) -> Self {
+ fn new(value: [u8; aead::NONCE_LEN]) -> Self {
Self(value)
}
#[cfg(feature = "tls12")]
pub(crate) fn copy(value: &[u8]) -> Self {
- debug_assert_eq!(value.len(), ring::aead::NONCE_LEN);
+ debug_assert_eq!(value.len(), aead::NONCE_LEN);
let mut iv = Self::new(Default::default());
iv.0.copy_from_slice(value);
iv
@@ -68,8 +68,8 @@ impl From<hkdf::Okm<'_, IvLen>> for Iv {
}
}
-pub(crate) fn make_nonce(iv: &Iv, seq: u64) -> ring::aead::Nonce {
- let mut nonce = [0u8; ring::aead::NONCE_LEN];
+pub(crate) fn make_nonce(iv: &Iv, seq: u64) -> aead::Nonce {
+ let mut nonce = [0u8; aead::NONCE_LEN];
codec::put_u64(seq, &mut nonce[4..]);
nonce
diff --git a/rustls/src/server/server_conn.rs b/rustls/src/server/server_conn.rs
index 1a65f065..8e751666 100644
--- a/rustls/src/server/server_conn.rs
+++ b/rustls/src/server/server_conn.rs
@@ -349,7 +349,7 @@ impl<'a> ReadEarlyData<'a> {
}
}
-impl<'a> std::io::Read for ReadEarlyData<'a> {
+impl<'a> io::Read for ReadEarlyData<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.early_data.read(buf)
}
diff --git a/rustls/src/ticketer.rs b/rustls/src/ticketer.rs
index 9660d711..54355e31 100644
--- a/rustls/src/ticketer.rs
+++ b/rustls/src/ticketer.rs
@@ -68,8 +68,8 @@ impl ProducesTickets for AeadTicketer {
// Random nonce, because a counter is a privacy leak.
let mut nonce_buf = [0u8; 12];
rand::fill_random(&mut nonce_buf).ok()?;
- let nonce = ring::aead::Nonce::assume_unique_for_key(nonce_buf);
- let aad = ring::aead::Aad::empty();
+ let nonce = aead::Nonce::assume_unique_for_key(nonce_buf);
+ let aad = aead::Aad::empty();
let mut ciphertext =
Vec::with_capacity(nonce_buf.len() + message.len() + self.key.algorithm().tag_len());
@@ -91,7 +91,7 @@ impl ProducesTickets for AeadTicketer {
let ciphertext = ciphertext.get(nonce.len()..)?;
// This won't fail since `nonce` has the required length.
- let nonce = ring::aead::Nonce::try_assume_unique_for_key(nonce).ok()?;
+ let nonce = aead::Nonce::try_assume_unique_for_key(nonce).ok()?;
let mut out = Vec::from(ciphertext);
diff --git a/rustls/src/tls12/cipher.rs b/rustls/src/tls12/cipher.rs
index 86225212..68c16965 100644
--- a/rustls/src/tls12/cipher.rs
+++ b/rustls/src/tls12/cipher.rs
@@ -16,13 +16,13 @@ fn make_tls12_aad(
typ: ContentType,
vers: ProtocolVersion,
len: usize,
-) -> ring::aead::Aad<[u8; TLS12_AAD_SIZE]> {
+) -> aead::Aad<[u8; TLS12_AAD_SIZE]> {
let mut out = [0; TLS12_AAD_SIZE];
codec::put_u64(seq, &mut out[0..]);
out[8] = typ.get_u8();
codec::put_u16(vers.get_u16(), &mut out[9..]);
codec::put_u16(len as u16, &mut out[11..]);
- ring::aead::Aad::from(out)
+ aead::Aad::from(out)
}
pub(crate) struct AesGcm;
diff --git a/rustls/src/tls12/mod.rs b/rustls/src/tls12/mod.rs
index 22b2aade..78fe00a8 100644
--- a/rustls/src/tls12/mod.rs
+++ b/rustls/src/tls12/mod.rs
@@ -26,7 +26,7 @@ pub static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
bulk: BulkAlgorithm::Chacha20Poly1305,
- aead_algorithm: &ring::aead::CHACHA20_POLY1305,
+ aead_algorithm: &aead::CHACHA20_POLY1305,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_ECDSA_SCHEMES,
@@ -42,7 +42,7 @@ pub static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
bulk: BulkAlgorithm::Chacha20Poly1305,
- aead_algorithm: &ring::aead::CHACHA20_POLY1305,
+ aead_algorithm: &aead::CHACHA20_POLY1305,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_RSA_SCHEMES,
@@ -58,7 +58,7 @@ pub static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
bulk: BulkAlgorithm::Aes128Gcm,
- aead_algorithm: &ring::aead::AES_128_GCM,
+ aead_algorithm: &aead::AES_128_GCM,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_RSA_SCHEMES,
@@ -74,7 +74,7 @@ pub static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
bulk: BulkAlgorithm::Aes256Gcm,
- aead_algorithm: &ring::aead::AES_256_GCM,
+ aead_algorithm: &aead::AES_256_GCM,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_RSA_SCHEMES,
@@ -90,7 +90,7 @@ pub static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
bulk: BulkAlgorithm::Aes128Gcm,
- aead_algorithm: &ring::aead::AES_128_GCM,
+ aead_algorithm: &aead::AES_128_GCM,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_ECDSA_SCHEMES,
@@ -106,7 +106,7 @@ pub static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
bulk: BulkAlgorithm::Aes256Gcm,
- aead_algorithm: &ring::aead::AES_256_GCM,
+ aead_algorithm: &aead::AES_256_GCM,
},
kx: KeyExchangeAlgorithm::ECDHE,
sign: TLS12_ECDSA_SCHEMES,
@@ -414,7 +414,7 @@ impl ConnectionSecrets {
iv: server_iv,
};
- let (client_secrets, server_secrets) = if algo == &ring::aead::AES_128_GCM {
+ let (client_secrets, server_secrets) = if algo == &aead::AES_128_GCM {
let extract = |pair: Pair| -> ConnectionTrafficSecrets {
let mut key = [0u8; 16];
key.copy_from_slice(pair.key);
@@ -429,7 +429,7 @@ impl ConnectionSecrets {
};
(extract(client_pair), extract(server_pair))
- } else if algo == &ring::aead::AES_256_GCM {
+ } else if algo == &aead::AES_256_GCM {
let extract = |pair: Pair| -> ConnectionTrafficSecrets {
let mut key = [0u8; 32];
key.copy_from_slice(pair.key);
@@ -444,7 +444,7 @@ impl ConnectionSecrets {
};
(extract(client_pair), extract(server_pair))
- } else if algo == &ring::aead::CHACHA20_POLY1305 {
+ } else if algo == &aead::CHACHA20_POLY1305 {
let extract = |pair: Pair| -> ConnectionTrafficSecrets {
let mut key = [0u8; 32];
key.copy_from_slice(pair.key);
diff --git a/rustls/src/tls13/mod.rs b/rustls/src/tls13/mod.rs
index 2c861470..472ea44f 100644
--- a/rustls/src/tls13/mod.rs
+++ b/rustls/src/tls13/mod.rs
@@ -22,7 +22,7 @@ pub(crate) static TLS13_CHACHA20_POLY1305_SHA256_INTERNAL: &Tls13CipherSuite = &
common: CipherSuiteCommon {
suite: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
bulk: BulkAlgorithm::Chacha20Poly1305,
- aead_algorithm: &ring::aead::CHACHA20_POLY1305,
+ aead_algorithm: &aead::CHACHA20_POLY1305,
},
hkdf_algorithm: ring::hkdf::HKDF_SHA256,
#[cfg(feature = "quic")]
@@ -37,7 +37,7 @@ pub static TLS13_AES_256_GCM_SHA384: SupportedCipherSuite =
common: CipherSuiteCommon {
suite: CipherSuite::TLS13_AES_256_GCM_SHA384,
bulk: BulkAlgorithm::Aes256Gcm,
- aead_algorithm: &ring::aead::AES_256_GCM,
+ aead_algorithm: &aead::AES_256_GCM,
},
hkdf_algorithm: ring::hkdf::HKDF_SHA384,
#[cfg(feature = "quic")]
@@ -54,7 +54,7 @@ pub(crate) static TLS13_AES_128_GCM_SHA256_INTERNAL: &Tls13CipherSuite = &Tls13C
common: CipherSuiteCommon {
suite: CipherSuite::TLS13_AES_128_GCM_SHA256,
bulk: BulkAlgorithm::Aes128Gcm,
- aead_algorithm: &ring::aead::AES_128_GCM,
+ aead_algorithm: &aead::AES_128_GCM,
},
hkdf_algorithm: ring::hkdf::HKDF_SHA256,
#[cfg(feature = "quic")]
@@ -129,8 +129,8 @@ fn unpad_tls13(v: &mut Vec<u8>) -> ContentType {
}
}
-fn make_tls13_aad(len: usize) -> ring::aead::Aad<[u8; TLS13_AAD_SIZE]> {
- ring::aead::Aad::from([
+fn make_tls13_aad(len: usize) -> aead::Aad<[u8; TLS13_AAD_SIZE]> {
+ aead::Aad::from([
0x17, // ContentType::ApplicationData
0x3, // ProtocolVersion (major)
0x3, // ProtocolVersion (minor)