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

Unified Diff: webrtc/p2p/base/turnserver.cc

Issue 1793553002: Using 64-bit timestamp in webrtc/p2p (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « webrtc/p2p/base/turnserver.h ('k') | webrtc/p2p/stunprober/main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/turnserver.cc
diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc
index 4754574076017d00987b64a66f93645c788c4683..14dcf05e89453cc4571b766f2cbb63f4dd551f56 100644
--- a/webrtc/p2p/base/turnserver.cc
+++ b/webrtc/p2p/base/turnserver.cc
@@ -35,7 +35,7 @@ static const int kMinChannelNumber = 0x4000;
static const int kMaxChannelNumber = 0x7FFF;
static const size_t kNonceKeySize = 16;
-static const size_t kNonceSize = 40;
+static const size_t kNonceSize = 48;
static const size_t TURN_CHANNEL_HEADER_SIZE = 4U;
@@ -392,12 +392,13 @@ void TurnServer::HandleAllocateRequest(TurnServerConnection* conn,
}
}
-std::string TurnServer::GenerateNonce(uint32_t now) const {
+std::string TurnServer::GenerateNonce(int64_t now) const {
// Generate a nonce of the form hex(now + HMAC-MD5(nonce_key_, now))
std::string input(reinterpret_cast<const char*>(&now), sizeof(now));
std::string nonce = rtc::hex_encode(input.c_str(), input.size());
nonce += rtc::ComputeHmac(rtc::DIGEST_MD5, nonce_key_, input);
ASSERT(nonce.size() == kNonceSize);
+
return nonce;
}
@@ -408,7 +409,7 @@ bool TurnServer::ValidateNonce(const std::string& nonce) const {
}
// Decode the timestamp.
- uint32_t then;
+ int64_t then;
char* p = reinterpret_cast<char*>(&then);
size_t len = rtc::hex_decode(p, sizeof(then),
nonce.substr(0, sizeof(then) * 2));
@@ -423,7 +424,7 @@ bool TurnServer::ValidateNonce(const std::string& nonce) const {
}
// Validate the timestamp.
- return rtc::TimeSince(then) < kNonceTimeout;
+ return rtc::Time64() - then < kNonceTimeout;
}
TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) {
@@ -464,7 +465,7 @@ void TurnServer::SendErrorResponseWithRealmAndNonce(
TurnMessage resp;
InitErrorResponse(msg, code, reason, &resp);
- uint32_t timestamp = rtc::Time();
+ int64_t timestamp = rtc::Time64();
if (ts_for_next_nonce_) {
timestamp = ts_for_next_nonce_;
ts_for_next_nonce_ = 0;
@@ -817,10 +818,10 @@ void TurnServerAllocation::OnExternalPacket(
int TurnServerAllocation::ComputeLifetime(const TurnMessage* msg) {
// Return the smaller of our default lifetime and the requested lifetime.
- uint32_t lifetime = kDefaultAllocationTimeout / 1000; // convert to seconds
+ int lifetime = kDefaultAllocationTimeout / 1000; // convert to seconds
const StunUInt32Attribute* lifetime_attr = msg->GetUInt32(STUN_ATTR_LIFETIME);
- if (lifetime_attr && lifetime_attr->value() < lifetime) {
- lifetime = lifetime_attr->value();
+ if (lifetime_attr && static_cast<int>(lifetime_attr->value()) < lifetime) {
+ lifetime = static_cast<int>(lifetime_attr->value());
}
return lifetime;
}
« no previous file with comments | « webrtc/p2p/base/turnserver.h ('k') | webrtc/p2p/stunprober/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698