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