Skip to content

Commit 667a71d

Browse files
committed
Reset KeyUpdate counter on AppData
1 parent 48b2fd9 commit 667a71d

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

rustls/src/common_state.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ impl CommonState {
481481
}
482482

483483
pub(crate) fn take_received_plaintext(&mut self, bytes: Payload<'_>) {
484+
self.temper_counters.received_app_data();
484485
self.received_plaintext
485486
.append(bytes.into_vec());
486487
}
@@ -964,6 +965,14 @@ impl TemperCounters {
964965
}
965966
}
966967
}
968+
969+
fn received_app_data(&mut self) {
970+
self.allowed_key_update_requests = Self::INITIAL_KEY_UPDATE_REQUESTS;
971+
}
972+
973+
// cf. BoringSSL `kMaxKeyUpdates`
974+
// <https://github.com/google/boringssl/blob/dec5989b793c56ad4dd32173bd2d8595ca78b398/ssl/tls13_both.cc#L35-L38>
975+
const INITIAL_KEY_UPDATE_REQUESTS: u8 = 32;
967976
}
968977

969978
impl Default for TemperCounters {
@@ -977,9 +986,7 @@ impl Default for TemperCounters {
977986
// a second request after this is fatal.
978987
allowed_renegotiation_requests: 1,
979988

980-
// cf. BoringSSL `kMaxKeyUpdates`
981-
// <https://github.com/google/boringssl/blob/dec5989b793c56ad4dd32173bd2d8595ca78b398/ssl/tls13_both.cc#L35-L38>
982-
allowed_key_update_requests: 32,
989+
allowed_key_update_requests: Self::INITIAL_KEY_UPDATE_REQUESTS,
983990

984991
// At most two CCS are allowed: one after each ClientHello (recall a second
985992
// ClientHello happens after a HelloRetryRequest).

0 commit comments

Comments
 (0)