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; |
} |