OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/proximity_auth/device_to_device_secure_context.h" | 5 #include "components/proximity_auth/device_to_device_secure_context.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/callback.h" | 10 #include "base/callback.h" |
9 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" | 11 #include "components/proximity_auth/cryptauth/proto/cryptauth_api.pb.h" |
10 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h" | 12 #include "components/proximity_auth/cryptauth/proto/securemessage.pb.h" |
11 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | 13 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" |
12 #include "components/proximity_auth/logging/logging.h" | 14 #include "components/proximity_auth/logging/logging.h" |
13 | 15 |
14 namespace proximity_auth { | 16 namespace proximity_auth { |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 // The version to put in the GcmMetadata field. | 20 // The version to put in the GcmMetadata field. |
19 const int kGcmMetadataVersion = 1; | 21 const int kGcmMetadataVersion = 1; |
20 | 22 |
21 // The sequence number of the last message used during authentication. These | 23 // The sequence number of the last message used during authentication. These |
22 // messages are sent and received before the SecureContext is created. | 24 // messages are sent and received before the SecureContext is created. |
23 const int kAuthenticationSequenceNumber = 2; | 25 const int kAuthenticationSequenceNumber = 2; |
24 | 26 |
25 } // namespace | 27 } // namespace |
26 | 28 |
27 DeviceToDeviceSecureContext::DeviceToDeviceSecureContext( | 29 DeviceToDeviceSecureContext::DeviceToDeviceSecureContext( |
28 scoped_ptr<SecureMessageDelegate> secure_message_delegate, | 30 scoped_ptr<SecureMessageDelegate> secure_message_delegate, |
29 const std::string& symmetric_key, | 31 const std::string& symmetric_key, |
30 const std::string& responder_auth_message, | 32 const std::string& responder_auth_message, |
31 ProtocolVersion protocol_version) | 33 ProtocolVersion protocol_version) |
32 : secure_message_delegate_(secure_message_delegate.Pass()), | 34 : secure_message_delegate_(std::move(secure_message_delegate)), |
33 symmetric_key_(symmetric_key), | 35 symmetric_key_(symmetric_key), |
34 responder_auth_message_(responder_auth_message), | 36 responder_auth_message_(responder_auth_message), |
35 protocol_version_(protocol_version), | 37 protocol_version_(protocol_version), |
36 last_sequence_number_(kAuthenticationSequenceNumber), | 38 last_sequence_number_(kAuthenticationSequenceNumber), |
37 weak_ptr_factory_(this) {} | 39 weak_ptr_factory_(this) {} |
38 | 40 |
39 DeviceToDeviceSecureContext::~DeviceToDeviceSecureContext() {} | 41 DeviceToDeviceSecureContext::~DeviceToDeviceSecureContext() {} |
40 | 42 |
41 void DeviceToDeviceSecureContext::Decode(const std::string& encoded_message, | 43 void DeviceToDeviceSecureContext::Decode(const std::string& encoded_message, |
42 const MessageCallback& callback) { | 44 const MessageCallback& callback) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 PA_LOG(ERROR) << "Failed to validate GcmMetadata."; | 112 PA_LOG(ERROR) << "Failed to validate GcmMetadata."; |
111 callback.Run(std::string()); | 113 callback.Run(std::string()); |
112 return; | 114 return; |
113 } | 115 } |
114 | 116 |
115 last_sequence_number_++; | 117 last_sequence_number_++; |
116 callback.Run(device_to_device_message.message()); | 118 callback.Run(device_to_device_message.message()); |
117 } | 119 } |
118 | 120 |
119 } // proximity_auth | 121 } // proximity_auth |
OLD | NEW |