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