Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1549)

Side by Side Diff: extensions/browser/api/cast_channel/cast_message_util.cc

Issue 2709523008: [Cast Channel] Add support for nonce challenge to Cast channel authentication. (Closed)
Patch Set: Addresses comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_message_util.h" 5 #include "extensions/browser/api/cast_channel/cast_message_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "extensions/browser/api/cast_channel/cast_auth_util.h"
12 #include "extensions/common/api/cast_channel.h" 13 #include "extensions/common/api/cast_channel.h"
13 #include "extensions/common/api/cast_channel/cast_channel.pb.h" 14 #include "extensions/common/api/cast_channel/cast_channel.pb.h"
14 15
15 namespace { 16 namespace {
16 static const char kAuthNamespace[] = 17 static const char kAuthNamespace[] =
17 "urn:x-cast:com.google.cast.tp.deviceauth"; 18 "urn:x-cast:com.google.cast.tp.deviceauth";
18 // Sender and receiver IDs to use for platform messages. 19 // Sender and receiver IDs to use for platform messages.
19 static const char kPlatformSenderId[] = "sender-0"; 20 static const char kPlatformSenderId[] = "sender-0";
20 static const char kPlatformReceiverId[] = "receiver-0"; 21 static const char kPlatformReceiverId[] = "receiver-0";
21 } // namespace 22 } // namespace
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 132 }
132 if (message.has_error()) { 133 if (message.has_error()) {
133 out += ", error: {"; 134 out += ", error: {";
134 out += base::IntToString(message.error().error_type()); 135 out += base::IntToString(message.error().error_type());
135 out += "}"; 136 out += "}";
136 } 137 }
137 out += "}"; 138 out += "}";
138 return out; 139 return out;
139 } 140 }
140 141
141 void CreateAuthChallengeMessage(CastMessage* message_proto) { 142 void CreateAuthChallengeMessage(CastMessage* message_proto,
143 const AuthContext* auth_context) {
144 DCHECK(auth_context);
142 CHECK(message_proto); 145 CHECK(message_proto);
143 DeviceAuthMessage auth_message; 146 DeviceAuthMessage auth_message;
144 auth_message.mutable_challenge(); 147 auth_message.mutable_challenge()->set_sender_nonce(auth_context->nonce());
145 std::string auth_message_string; 148 std::string auth_message_string;
146 auth_message.SerializeToString(&auth_message_string); 149 auth_message.SerializeToString(&auth_message_string);
147 150
148 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0); 151 message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0);
149 message_proto->set_source_id(kPlatformSenderId); 152 message_proto->set_source_id(kPlatformSenderId);
150 message_proto->set_destination_id(kPlatformReceiverId); 153 message_proto->set_destination_id(kPlatformReceiverId);
151 message_proto->set_namespace_(kAuthNamespace); 154 message_proto->set_namespace_(kAuthNamespace);
152 message_proto->set_payload_type(CastMessage_PayloadType_BINARY); 155 message_proto->set_payload_type(CastMessage_PayloadType_BINARY);
153 message_proto->set_payload_binary(auth_message_string); 156 message_proto->set_payload_binary(auth_message_string);
154 } 157 }
155 158
156 bool IsAuthMessage(const CastMessage& message) { 159 bool IsAuthMessage(const CastMessage& message) {
157 return message.namespace_() == kAuthNamespace; 160 return message.namespace_() == kAuthNamespace;
158 } 161 }
159 162
160 } // namespace cast_channel 163 } // namespace cast_channel
161 } // namespace api 164 } // namespace api
162 } // namespace extensions 165 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698