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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 scoped_ptr<buzz::XmlElement> V2Authenticator::GetNextMessage() { | 150 scoped_ptr<buzz::XmlElement> V2Authenticator::GetNextMessage() { |
151 DCHECK_EQ(state(), MESSAGE_READY); | 151 DCHECK_EQ(state(), MESSAGE_READY); |
152 | 152 |
153 scoped_ptr<buzz::XmlElement> message = CreateEmptyAuthenticatorMessage(); | 153 scoped_ptr<buzz::XmlElement> message = CreateEmptyAuthenticatorMessage(); |
154 | 154 |
155 DCHECK(!pending_messages_.empty()); | 155 DCHECK(!pending_messages_.empty()); |
156 while (!pending_messages_.empty()) { | 156 while (!pending_messages_.empty()) { |
157 const std::string& spake_message = pending_messages_.front(); | 157 const std::string& spake_message = pending_messages_.front(); |
158 std::string base64_message; | 158 std::string base64_message; |
159 if (!base::Base64Encode(spake_message, &base64_message)) { | 159 base::Base64Encode(spake_message, &base64_message); |
160 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; | |
161 continue; | |
162 } | |
163 | 160 |
164 buzz::XmlElement* eke_tag = new buzz::XmlElement(kEkeTag); | 161 buzz::XmlElement* eke_tag = new buzz::XmlElement(kEkeTag); |
165 eke_tag->SetBodyText(base64_message); | 162 eke_tag->SetBodyText(base64_message); |
166 message->AddElement(eke_tag); | 163 message->AddElement(eke_tag); |
167 | 164 |
168 pending_messages_.pop(); | 165 pending_messages_.pop(); |
169 } | 166 } |
170 | 167 |
171 if (!local_cert_.empty() && !certificate_sent_) { | 168 if (!local_cert_.empty() && !certificate_sent_) { |
172 buzz::XmlElement* certificate_tag = new buzz::XmlElement(kCertificateTag); | 169 buzz::XmlElement* certificate_tag = new buzz::XmlElement(kCertificateTag); |
173 std::string base64_cert; | 170 std::string base64_cert; |
174 if (!base::Base64Encode(local_cert_, &base64_cert)) { | 171 base::Base64Encode(local_cert_, &base64_cert); |
175 LOG(DFATAL) << "Cannot perform base64 encode on certificate"; | |
176 } | |
177 certificate_tag->SetBodyText(base64_cert); | 172 certificate_tag->SetBodyText(base64_cert); |
178 message->AddElement(certificate_tag); | 173 message->AddElement(certificate_tag); |
179 certificate_sent_ = true; | 174 certificate_sent_ = true; |
180 } | 175 } |
181 | 176 |
182 if (state_ != ACCEPTED) { | 177 if (state_ != ACCEPTED) { |
183 state_ = WAITING_MESSAGE; | 178 state_ = WAITING_MESSAGE; |
184 } | 179 } |
185 return message.Pass(); | 180 return message.Pass(); |
186 } | 181 } |
(...skipping 13 matching lines...) Expand all Loading... |
200 remote_cert_, auth_key_).Pass()); | 195 remote_cert_, auth_key_).Pass()); |
201 } | 196 } |
202 } | 197 } |
203 | 198 |
204 bool V2Authenticator::is_host_side() const { | 199 bool V2Authenticator::is_host_side() const { |
205 return local_key_pair_.get() != NULL; | 200 return local_key_pair_.get() != NULL; |
206 } | 201 } |
207 | 202 |
208 } // namespace protocol | 203 } // namespace protocol |
209 } // namespace remoting | 204 } // namespace remoting |
OLD | NEW |