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

Side by Side Diff: components/cryptauth/device_to_device_secure_context.h

Issue 2899863002: Updating D2D protocol to v1 to support separate sequence numbers. (Closed)
Patch Set: Addressing comments Created 3 years, 7 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 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 #ifndef COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_ 5 #ifndef COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_
6 #define COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_ 6 #define COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "components/cryptauth/secure_context.h" 12 #include "components/cryptauth/secure_context.h"
13 #include "components/cryptauth/session_keys.h"
13 14
14 namespace securemessage { 15 namespace securemessage {
15 class Header; 16 class Header;
16 } 17 }
17 18
18 namespace cryptauth { 19 namespace cryptauth {
19 20
20 class SecureMessageDelegate; 21 class SecureMessageDelegate;
21 22
22 // SecureContext implementation for the DeviceToDevice protocol. 23 // SecureContext implementation for the DeviceToDevice protocol.
23 class DeviceToDeviceSecureContext : public SecureContext { 24 class DeviceToDeviceSecureContext : public SecureContext {
24 public: 25 public:
25 DeviceToDeviceSecureContext( 26 DeviceToDeviceSecureContext(
26 std::unique_ptr<SecureMessageDelegate> secure_message_delegate, 27 std::unique_ptr<SecureMessageDelegate> secure_message_delegate,
27 const std::string& symmetric_key, 28 const SessionKeys& session_keys,
28 const std::string& responder_auth_message_, 29 const std::string& responder_auth_message_,
29 ProtocolVersion protocol_version); 30 ProtocolVersion protocol_version);
30 31
31 ~DeviceToDeviceSecureContext() override; 32 ~DeviceToDeviceSecureContext() override;
32 33
33 // SecureContext: 34 // SecureContext:
34 void Decode(const std::string& encoded_message, 35 void Decode(const std::string& encoded_message,
35 const MessageCallback& callback) override; 36 const MessageCallback& callback) override;
36 void Encode(const std::string& message, 37 void Encode(const std::string& message,
37 const MessageCallback& callback) override; 38 const MessageCallback& callback) override;
38 ProtocolVersion GetProtocolVersion() const override; 39 ProtocolVersion GetProtocolVersion() const override;
39 std::string GetChannelBindingData() const override; 40 std::string GetChannelBindingData() const override;
40 41
41 private: 42 private:
42 // Callback for unwrapping a secure message. |callback| will be invoked with 43 // Callback for unwrapping a secure message. |callback| will be invoked with
43 // the decrypted payload if the message is unwrapped successfully; otherwise 44 // the decrypted payload if the message is unwrapped successfully; otherwise
44 // it will be invoked with an empty string. 45 // it will be invoked with an empty string.
45 void HandleUnwrapResult( 46 void HandleUnwrapResult(
46 const DeviceToDeviceSecureContext::MessageCallback& callback, 47 const DeviceToDeviceSecureContext::MessageCallback& callback,
47 bool verified, 48 bool verified,
48 const std::string& payload, 49 const std::string& payload,
49 const securemessage::Header& header); 50 const securemessage::Header& header);
50 51
51 // Delegate for handling the creation and unwrapping of SecureMessages. 52 // Delegate for handling the creation and unwrapping of SecureMessages.
52 std::unique_ptr<SecureMessageDelegate> secure_message_delegate_; 53 std::unique_ptr<SecureMessageDelegate> secure_message_delegate_;
53 54
54 // The symmetric key used to create and unwrap messages. 55 // The symmetric key used for encryption.
55 const std::string symmetric_key_; 56 const std::string encryption_key_;
57
58 // The symmetric key used for decryption.
59 const std::string decryption_key_;
56 60
57 // The [Responder Auth] message received from the remote device during 61 // The [Responder Auth] message received from the remote device during
58 // authentication. 62 // authentication.
59 const std::string responder_auth_message_; 63 const std::string responder_auth_message_;
60 64
61 // The protocol version supported by the remote device. 65 // The protocol version supported by the remote device.
62 const ProtocolVersion protocol_version_; 66 const ProtocolVersion protocol_version_;
63 67
64 // The last sequence number of the message sent or received. 68 // The last sequence number of the message sent.
65 int last_sequence_number_; 69 int last_encode_sequence_number_;
70
71 // The last sequence number of the message received.
72 int last_decode_sequence_number_;
66 73
67 base::WeakPtrFactory<DeviceToDeviceSecureContext> weak_ptr_factory_; 74 base::WeakPtrFactory<DeviceToDeviceSecureContext> weak_ptr_factory_;
68 75
69 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceSecureContext); 76 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceSecureContext);
70 }; 77 };
71 78
72 } // namespace cryptauth 79 } // namespace cryptauth
73 80
74 #endif // COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_ 81 #endif // COMPONENTS_CRYPTAUTH_DEVICE_TO_DEVICE_SECURE_CONTEXT_H_
OLDNEW
« no previous file with comments | « components/cryptauth/device_to_device_responder_operations.cc ('k') | components/cryptauth/device_to_device_secure_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698