Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1596)

Unified Diff: net/quic/crypto/strike_register.cc

Issue 388333005: Reject reasons from strike register when nonce validation fails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/quic/crypto/strike_register.cc
diff --git a/net/quic/crypto/strike_register.cc b/net/quic/crypto/strike_register.cc
index cd58279897c1a43a557625fcc9ffe9f4d826ebeb..7719a64ab4c6e41572e68131d0199cf0c8a375c0 100644
--- a/net/quic/crypto/strike_register.cc
+++ b/net/quic/crypto/strike_register.cc
@@ -128,8 +128,8 @@ void StrikeRegister::Reset() {
internal_node_head_ = kNil;
}
-bool StrikeRegister::Insert(const uint8 nonce[32],
- uint32 current_time_external) {
+InsertStatus StrikeRegister::Insert(const uint8 nonce[32],
+ uint32 current_time_external) {
// Make space for the insertion if the strike register is full.
while (external_node_free_head_ == kNil ||
internal_node_free_head_ == kNil) {
@@ -140,7 +140,7 @@ bool StrikeRegister::Insert(const uint8 nonce[32],
// Check to see if the orbit is correct.
if (memcmp(nonce + sizeof(current_time), orbit_, sizeof(orbit_))) {
- return false;
+ return NONCE_INVALID_ORBIT_FAILURE;
}
const uint32 nonce_time = ExternalTimeToInternal(TimeFromBytes(nonce));
@@ -149,7 +149,7 @@ bool StrikeRegister::Insert(const uint8 nonce[32],
pair<uint32, uint32> valid_range =
StrikeRegister::GetValidRange(current_time);
if (nonce_time < valid_range.first || nonce_time > valid_range.second) {
- return false;
+ return NONCE_INVALID_TIME_FAILURE;
}
// We strip the orbit out of the nonce.
@@ -169,13 +169,13 @@ bool StrikeRegister::Insert(const uint8 nonce[32],
memcpy(external_node(index), value, sizeof(value));
internal_node_head_ = (index | kExternalFlag) << 8;
DCHECK_LE(horizon_, nonce_time);
- return true;
+ return NONCE_OK;
}
const uint8* best_match = external_node(best_match_index);
if (memcmp(best_match, value, sizeof(value)) == 0) {
// We found the value in the tree.
- return false;
+ return NONCE_NOT_UNIQUE_FAILURE;
}
// We are going to insert a new entry into the tree, so get the nodes now.
@@ -261,7 +261,7 @@ bool StrikeRegister::Insert(const uint8 nonce[32],
*where_index = (*where_index & 0xff) | (internal_node_index << 8);
DCHECK_LE(horizon_, nonce_time);
- return true;
+ return NONCE_OK;
}
const uint8* StrikeRegister::orbit() const {

Powered by Google App Engine
This is Rietveld 408576698