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

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

Issue 1595613004: Reset TURN port NONCE when a new socket is created. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: merge with head Created 4 years, 11 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') | no next file » | 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 1502cdd52eda2e71c64be059d576bb6b006ba8fc..4754574076017d00987b64a66f93645c788c4683 100644
--- a/webrtc/p2p/base/turnserver.cc
+++ b/webrtc/p2p/base/turnserver.cc
@@ -392,9 +392,8 @@ void TurnServer::HandleAllocateRequest(TurnServerConnection* conn,
}
}
-std::string TurnServer::GenerateNonce() const {
+std::string TurnServer::GenerateNonce(uint32_t now) const {
// Generate a nonce of the form hex(now + HMAC-MD5(nonce_key_, now))
- uint32_t now = rtc::Time();
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);
@@ -464,8 +463,14 @@ void TurnServer::SendErrorResponseWithRealmAndNonce(
int code, const std::string& reason) {
TurnMessage resp;
InitErrorResponse(msg, code, reason, &resp);
- VERIFY(resp.AddAttribute(new StunByteStringAttribute(
- STUN_ATTR_NONCE, GenerateNonce())));
+
+ uint32_t timestamp = rtc::Time();
+ if (ts_for_next_nonce_) {
+ timestamp = ts_for_next_nonce_;
+ ts_for_next_nonce_ = 0;
+ }
+ VERIFY(resp.AddAttribute(
+ new StunByteStringAttribute(STUN_ATTR_NONCE, GenerateNonce(timestamp))));
VERIFY(resp.AddAttribute(new StunByteStringAttribute(
STUN_ATTR_REALM, realm_)));
SendStun(conn, &resp);
« no previous file with comments | « webrtc/p2p/base/turnserver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698