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

Side by Side Diff: net/quic/crypto/strike_register_test.cc

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « net/quic/crypto/strike_register.cc ('k') | net/quic/quic_ack_notifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/crypto/strike_register.h" 5 #include "net/quic/crypto/strike_register.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/rand_util.h" 11 #include "base/rand_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 15
16 using net::InsertStatus; 16 using net::InsertStatus;
17 using net::StrikeRegister; 17 using net::StrikeRegister;
18 using std::make_pair;
19 using std::min; 18 using std::min;
20 using std::pair; 19 using std::pair;
21 using std::set; 20 using std::set;
22 using std::string; 21 using std::string;
23 22
24 const uint8 kOrbit[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; 23 const uint8 kOrbit[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
25 24
26 // StrikeRegisterTests don't look at the random bytes so this function can 25 // StrikeRegisterTests don't look at the random bytes so this function can
27 // simply set the random bytes to 0. 26 // simply set the random bytes to 0.
28 void SetNonce(uint8 nonce[32], unsigned time, const uint8 orbit[8]) { 27 void SetNonce(uint8 nonce[32], unsigned time, const uint8 orbit[8]) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return net::NONCE_INVALID_TIME_FAILURE; 224 return net::NONCE_INVALID_TIME_FAILURE;
226 } 225 }
227 226
228 // Check that the timestamp is in the current window. 227 // Check that the timestamp is in the current window.
229 if ((current_time > window_secs_ && 228 if ((current_time > window_secs_ &&
230 nonce_time < (current_time - window_secs_)) || 229 nonce_time < (current_time - window_secs_)) ||
231 nonce_time > (current_time + window_secs_)) { 230 nonce_time > (current_time + window_secs_)) {
232 return net::NONCE_INVALID_TIME_FAILURE; 231 return net::NONCE_INVALID_TIME_FAILURE;
233 } 232 }
234 233
235 pair<uint32, string> nonce = make_pair( 234 pair<uint32, string> nonce = std::make_pair(
236 nonce_time, 235 nonce_time, string(reinterpret_cast<const char*>(nonce_bytes), 32));
237 string(reinterpret_cast<const char*>(nonce_bytes), 32));
238 236
239 set<pair<uint32, string> >::const_iterator it = nonces_.find(nonce); 237 set<pair<uint32, string> >::const_iterator it = nonces_.find(nonce);
240 if (it != nonces_.end()) { 238 if (it != nonces_.end()) {
241 return net::NONCE_NOT_UNIQUE_FAILURE; 239 return net::NONCE_NOT_UNIQUE_FAILURE;
242 } 240 }
243 241
244 nonces_.insert(nonce); 242 nonces_.insert(nonce);
245 return net::NONCE_OK; 243 return net::NONCE_OK;
246 } 244 }
247 245
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 break; 397 break;
400 } 398 }
401 } 399 }
402 400
403 if (i != kMaxIterations) { 401 if (i != kMaxIterations) {
404 FAIL() << "Failed after " << i << " iterations"; 402 FAIL() << "Failed after " << i << " iterations";
405 } 403 }
406 } 404 }
407 405
408 } // anonymous namespace 406 } // anonymous namespace
OLDNEW
« no previous file with comments | « net/quic/crypto/strike_register.cc ('k') | net/quic/quic_ack_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698