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