Index: webrtc/p2p/base/turnserver.cc |
diff --git a/webrtc/p2p/base/turnserver.cc b/webrtc/p2p/base/turnserver.cc |
index 1502cdd52eda2e71c64be059d576bb6b006ba8fc..976dd33cafc2ab6a3e06ca81c37aaef71c3a8800 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,11 @@ 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 = |
+ ts_for_next_nonce_ != 0 ? ts_for_next_nonce_ : rtc::Time(); |
+ 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); |