blob: 3fa693295193b3e111f7235f2c1c4a732ea95a6e [file] [log] [blame]
isherman40e54e02014-10-15 02:20:071// 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
khorimotocec3fb22017-01-20 02:06:485#ifndef COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_
6#define COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_
isherman40e54e02014-10-15 02:20:077
tengs258deb02015-07-27 19:44:118#include "base/callback_forward.h"
9
khorimotocec3fb22017-01-20 02:06:4810namespace cryptauth {
isherman40e54e02014-10-15 02:20:0711
12// An interface used to decode and encode messages.
13class SecureContext {
14 public:
tengs258deb02015-07-27 19:44:1115 typedef base::Callback<void(const std::string& message)> MessageCallback;
16
isherman40e54e02014-10-15 02:20:0717 // 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.
tengs258deb02015-07-27 19:44:1126 // 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;
isherman40e54e02014-10-15 02:20:0730
31 // Encodes the |message| and returns the result.
tengs258deb02015-07-27 19:44:1132 // 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;
isherman40e54e02014-10-15 02:20:0736
37 // Returns the protocol version that was used during authentication.
38 virtual ProtocolVersion GetProtocolVersion() const = 0;
tengsa85897c22015-10-29 01:12:0039
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;
isherman40e54e02014-10-15 02:20:0743};
44
khorimotocec3fb22017-01-20 02:06:4845} // namespace cryptauth
isherman40e54e02014-10-15 02:20:0746
khorimotocec3fb22017-01-20 02:06:4847#endif // COMPONENTS_CRYPTAUTH_SECURE_CONTEXT_H_