| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/v2_authenticator.h" | 5 #include "remoting/protocol/v2_authenticator.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/base/rsa_key_pair.h" | 10 #include "remoting/base/rsa_key_pair.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 V2Authenticator::V2Authenticator( | 58 V2Authenticator::V2Authenticator( |
| 59 crypto::P224EncryptedKeyExchange::PeerType type, | 59 crypto::P224EncryptedKeyExchange::PeerType type, |
| 60 const std::string& shared_secret, | 60 const std::string& shared_secret, |
| 61 Authenticator::State initial_state) | 61 Authenticator::State initial_state) |
| 62 : certificate_sent_(false), | 62 : certificate_sent_(false), |
| 63 key_exchange_impl_(type, shared_secret), | 63 key_exchange_impl_(type, shared_secret), |
| 64 state_(initial_state), | 64 state_(initial_state), |
| 65 started_(false), | 65 started_(false), |
| 66 rejection_reason_(INVALID_CREDENTIALS) { | 66 rejection_reason_(INVALID_CREDENTIALS) { |
| 67 pending_messages_.push(key_exchange_impl_.GetMessage()); | 67 pending_messages_.push(key_exchange_impl_.GetNextMessage()); |
| 68 } | 68 } |
| 69 | 69 |
| 70 V2Authenticator::~V2Authenticator() { | 70 V2Authenticator::~V2Authenticator() { |
| 71 } | 71 } |
| 72 | 72 |
| 73 Authenticator::State V2Authenticator::state() const { | 73 Authenticator::State V2Authenticator::state() const { |
| 74 if (state_ == ACCEPTED && !pending_messages_.empty()) | 74 if (state_ == ACCEPTED && !pending_messages_.empty()) |
| 75 return MESSAGE_READY; | 75 return MESSAGE_READY; |
| 76 return state_; | 76 return state_; |
| 77 } | 77 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 state_ = REJECTED; | 128 state_ = REJECTED; |
| 129 rejection_reason_ = PROTOCOL_ERROR; | 129 rejection_reason_ = PROTOCOL_ERROR; |
| 130 return; | 130 return; |
| 131 } | 131 } |
| 132 | 132 |
| 133 P224EncryptedKeyExchange::Result result = | 133 P224EncryptedKeyExchange::Result result = |
| 134 key_exchange_impl_.ProcessMessage(spake_message); | 134 key_exchange_impl_.ProcessMessage(spake_message); |
| 135 started_ = true; | 135 started_ = true; |
| 136 switch (result) { | 136 switch (result) { |
| 137 case P224EncryptedKeyExchange::kResultPending: | 137 case P224EncryptedKeyExchange::kResultPending: |
| 138 pending_messages_.push(key_exchange_impl_.GetMessage()); | 138 pending_messages_.push(key_exchange_impl_.GetNextMessage()); |
| 139 break; | 139 break; |
| 140 | 140 |
| 141 case P224EncryptedKeyExchange::kResultFailed: | 141 case P224EncryptedKeyExchange::kResultFailed: |
| 142 state_ = REJECTED; | 142 state_ = REJECTED; |
| 143 rejection_reason_ = INVALID_CREDENTIALS; | 143 rejection_reason_ = INVALID_CREDENTIALS; |
| 144 return; | 144 return; |
| 145 | 145 |
| 146 case P224EncryptedKeyExchange::kResultSuccess: | 146 case P224EncryptedKeyExchange::kResultSuccess: |
| 147 auth_key_ = key_exchange_impl_.GetKey(); | 147 auth_key_ = key_exchange_impl_.GetKey(); |
| 148 state_ = ACCEPTED; | 148 state_ = ACCEPTED; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 remote_cert_, auth_key_); | 198 remote_cert_, auth_key_); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool V2Authenticator::is_host_side() const { | 202 bool V2Authenticator::is_host_side() const { |
| 203 return local_key_pair_.get() != nullptr; | 203 return local_key_pair_.get() != nullptr; |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace protocol | 206 } // namespace protocol |
| 207 } // namespace remoting | 207 } // namespace remoting |
| OLD | NEW |