| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/jingle_session.h" | 5 #include "remoting/protocol/jingle_session.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Generates channel key from master key and channel name. Must be | 66 // Generates channel key from master key and channel name. Must be |
| 67 // used to generate channel key so that we don't use the same key for | 67 // used to generate channel key so that we don't use the same key for |
| 68 // different channels. The key is calculated as | 68 // different channels. The key is calculated as |
| 69 // HMAC_SHA256(master_key, channel_name) | 69 // HMAC_SHA256(master_key, channel_name) |
| 70 bool GetChannelKey(const std::string& channel_name, | 70 bool GetChannelKey(const std::string& channel_name, |
| 71 const std::string& master_key, | 71 const std::string& master_key, |
| 72 std::string* channel_key) { | 72 std::string* channel_key) { |
| 73 crypto::HMAC hmac(crypto::HMAC::SHA256); | 73 crypto::HMAC hmac(crypto::HMAC::SHA256); |
| 74 hmac.Init(channel_name); | 74 if (!hmac.Init(channel_name)) { |
| 75 channel_key->clear(); |
| 76 return false; |
| 77 } |
| 75 channel_key->resize(kChannelKeyLength); | 78 channel_key->resize(kChannelKeyLength); |
| 76 if (!hmac.Sign(master_key, | 79 if (!hmac.Sign(master_key, |
| 77 reinterpret_cast<unsigned char*>(&(*channel_key)[0]), | 80 reinterpret_cast<unsigned char*>(&(*channel_key)[0]), |
| 78 channel_key->size())) { | 81 channel_key->size())) { |
| 79 *channel_key = ""; | 82 channel_key->clear(); |
| 80 return false; | 83 return false; |
| 81 } | 84 } |
| 82 return true; | 85 return true; |
| 83 } | 86 } |
| 84 | 87 |
| 85 } // namespace | 88 } // namespace |
| 86 | 89 |
| 87 // static | 90 // static |
| 88 JingleSession* JingleSession::CreateClientSession( | 91 JingleSession* JingleSession::CreateClientSession( |
| 89 JingleSessionManager* manager, const std::string& host_public_key) { | 92 JingleSessionManager* manager, const std::string& host_public_key) { |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 584 |
| 582 state_ = new_state; | 585 state_ = new_state; |
| 583 if (!closed_ && state_change_callback_.get()) | 586 if (!closed_ && state_change_callback_.get()) |
| 584 state_change_callback_->Run(new_state); | 587 state_change_callback_->Run(new_state); |
| 585 } | 588 } |
| 586 } | 589 } |
| 587 | 590 |
| 588 } // namespace protocol | 591 } // namespace protocol |
| 589 | 592 |
| 590 } // namespace remoting | 593 } // namespace remoting |
| OLD | NEW |