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 "crypto/rsa_private_key.h" | 9 #include "crypto/rsa_private_key.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 case P224EncryptedKeyExchange::kResultSuccess: | 122 case P224EncryptedKeyExchange::kResultSuccess: |
123 auth_key_ = key_exchange_impl_.GetKey(); | 123 auth_key_ = key_exchange_impl_.GetKey(); |
124 state_ = ACCEPTED; | 124 state_ = ACCEPTED; |
125 return; | 125 return; |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 state_ = MESSAGE_READY; | 129 state_ = MESSAGE_READY; |
130 } | 130 } |
131 | 131 |
132 buzz::XmlElement* V2Authenticator::GetNextMessage() { | 132 scoped_ptr<buzz::XmlElement> V2Authenticator::GetNextMessage() { |
133 DCHECK_EQ(state(), MESSAGE_READY); | 133 DCHECK_EQ(state(), MESSAGE_READY); |
134 | 134 |
135 buzz::XmlElement* message = CreateEmptyAuthenticatorMessage(); | 135 scoped_ptr<buzz::XmlElement> message = CreateEmptyAuthenticatorMessage(); |
136 | 136 |
137 DCHECK(!pending_messages_.empty()); | 137 DCHECK(!pending_messages_.empty()); |
138 while (!pending_messages_.empty()) { | 138 while (!pending_messages_.empty()) { |
139 const std::string& spake_message = pending_messages_.front(); | 139 const std::string& spake_message = pending_messages_.front(); |
140 std::string base64_message; | 140 std::string base64_message; |
141 if (!base::Base64Encode(spake_message, &base64_message)) { | 141 if (!base::Base64Encode(spake_message, &base64_message)) { |
142 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; | 142 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; |
143 continue; | 143 continue; |
144 } | 144 } |
145 | 145 |
(...skipping 10 matching lines...) Expand all Loading... | |
156 if (!base::Base64Encode(local_cert_, &base64_cert)) { | 156 if (!base::Base64Encode(local_cert_, &base64_cert)) { |
157 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; | 157 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; |
158 } | 158 } |
159 certificate_tag->SetBodyText(base64_cert); | 159 certificate_tag->SetBodyText(base64_cert); |
160 message->AddElement(certificate_tag); | 160 message->AddElement(certificate_tag); |
161 } | 161 } |
162 | 162 |
163 if (state_ != ACCEPTED) { | 163 if (state_ != ACCEPTED) { |
164 state_ = WAITING_MESSAGE; | 164 state_ = WAITING_MESSAGE; |
165 } | 165 } |
166 return message; | 166 return message.Pass(); |
167 } | 167 } |
168 | 168 |
169 ChannelAuthenticator* V2Authenticator::CreateChannelAuthenticator() const { | 169 scoped_ptr<ChannelAuthenticator> |
170 V2Authenticator::CreateChannelAuthenticator() const { | |
170 DCHECK_EQ(state(), ACCEPTED); | 171 DCHECK_EQ(state(), ACCEPTED); |
171 CHECK(!auth_key_.empty()); | 172 CHECK(!auth_key_.empty()); |
172 | 173 |
173 if (is_host_side()) { | 174 if (is_host_side()) { |
174 return SslHmacChannelAuthenticator::CreateForHost( | 175 return scoped_ptr<ChannelAuthenticator>( |
175 local_cert_, local_private_key_.get(), auth_key_); | 176 SslHmacChannelAuthenticator::CreateForHost( |
177 local_cert_, local_private_key_.get(), auth_key_).release()); | |
Wez
2012/01/19 03:18:17
.Pass()?
Sergey Ulanov
2012/01/19 20:11:42
Done.
| |
176 } else { | 178 } else { |
177 return SslHmacChannelAuthenticator::CreateForClient( | 179 return scoped_ptr<ChannelAuthenticator>( |
178 remote_cert_, auth_key_); | 180 SslHmacChannelAuthenticator::CreateForClient( |
181 remote_cert_, auth_key_).release()); | |
Wez
2012/01/19 03:18:17
.Pass()?
Sergey Ulanov
2012/01/19 20:11:42
Done.
| |
179 } | 182 } |
180 } | 183 } |
181 | 184 |
182 bool V2Authenticator::is_host_side() const { | 185 bool V2Authenticator::is_host_side() const { |
183 return local_private_key_.get() != NULL; | 186 return local_private_key_.get() != NULL; |
184 } | 187 } |
185 | 188 |
186 } // namespace protocol | 189 } // namespace protocol |
187 } // namespace remoting | 190 } // namespace remoting |
OLD | NEW |