isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
khorimoto | cec3fb2 | 2017-01-20 02:06:48 | [diff] [blame] | 5 | #ifndef COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_ |
| 6 | #define COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_ |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 7 | |
tengs | 258deb0 | 2015-07-27 19:44:11 | [diff] [blame] | 8 | #include "base/callback_forward.h" |
| 9 | |
khorimoto | cec3fb2 | 2017-01-20 02:06:48 | [diff] [blame] | 10 | namespace cryptauth { |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 11 | |
| 12 | // An interface used to decode and encode messages. |
| 13 | class SecureContext { |
| 14 | public: |
tengs | 258deb0 | 2015-07-27 19:44:11 | [diff] [blame] | 15 | typedef base::Callback<void(const std::string& message)> MessageCallback; |
| 16 | |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 17 | // The protocol version used during authentication. |
| 18 | enum ProtocolVersion { |
| 19 | PROTOCOL_VERSION_THREE_ZERO, // 3.0 |
| 20 | PROTOCOL_VERSION_THREE_ONE, // 3.1 |
| 21 | }; |
| 22 | |
| 23 | virtual ~SecureContext() {} |
| 24 | |
| 25 | // Decodes the |encoded_message| and returns the result. |
tengs | 258deb0 | 2015-07-27 19:44:11 | [diff] [blame] | 26 | // This function is asynchronous because the ChromeOS implementation requires |
| 27 | // a DBus call. |
| 28 | virtual void Decode(const std::string& encoded_message, |
| 29 | const MessageCallback& callback) = 0; |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 30 | |
| 31 | // Encodes the |message| and returns the result. |
tengs | 258deb0 | 2015-07-27 19:44:11 | [diff] [blame] | 32 | // This function is asynchronous because the ChromeOS implementation requires |
| 33 | // a DBus call. |
| 34 | virtual void Encode(const std::string& message, |
| 35 | const MessageCallback& callback) = 0; |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 36 | |
| 37 | // Returns the protocol version that was used during authentication. |
| 38 | virtual ProtocolVersion GetProtocolVersion() const = 0; |
tengs | a85897c2 | 2015-10-29 01:12:00 | [diff] [blame] | 39 | |
| 40 | // Returns data specific to the current session that can be used in |
| 41 | // cryptographic operations to bind to the channel. |
| 42 | virtual std::string GetChannelBindingData() const = 0; |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 43 | }; |
| 44 | |
khorimoto | cec3fb2 | 2017-01-20 02:06:48 | [diff] [blame] | 45 | } // namespace cryptauth |
isherman | 40e54e0 | 2014-10-15 02:20:07 | [diff] [blame] | 46 | |
khorimoto | cec3fb2 | 2017-01-20 02:06:48 | [diff] [blame] | 47 | #endif // COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_ |