1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/quic/crypto/local_strike_register_client.h"
7 #include "net/quic/crypto/crypto_protocol.h"
9 using base::StringPiece
;
14 LocalStrikeRegisterClient::LocalStrikeRegisterClient(
16 uint32 current_time_external
,
19 StrikeRegister::StartupType startup
)
20 : strike_register_(max_entries
, current_time_external
, window_secs
,
24 bool LocalStrikeRegisterClient::IsKnownOrbit(StringPiece orbit
) const {
25 base::AutoLock
lock(m_
);
26 if (orbit
.length() != kOrbitSize
) {
29 return memcmp(orbit
.data(), strike_register_
.orbit(), kOrbitSize
) == 0;
32 void LocalStrikeRegisterClient::VerifyNonceIsValidAndUnique(
33 StringPiece nonce
, QuicWallTime now
, ResultCallback
* cb
) {
34 bool nonce_is_valid_and_unique
;
35 if (nonce
.length() != kNonceSize
) {
36 nonce_is_valid_and_unique
= false;
38 base::AutoLock
lock(m_
);
39 nonce_is_valid_and_unique
= strike_register_
.Insert(
40 reinterpret_cast<const uint8
*>(nonce
.data()),
41 static_cast<uint32
>(now
.ToUNIXSeconds()));
44 // m_ must not be held when the ResultCallback runs.
45 cb
->Run(nonce_is_valid_and_unique
);