5053a9928c7eba3002ae3fda2d0a5a927ff80078
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / easy_unlock_private / easy_unlock_private_crypto_delegate.h
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
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/common/extensions/api/easy_unlock_private.h"
13
14 namespace extensions {
15 namespace api {
16
17 // Wrapper around EasyUnlock dbus client on ChromeOS. On other platforms, the
18 // methods are stubbed out.
19 class EasyUnlockPrivateCryptoDelegate {
20  public:
21   typedef base::Callback<void(const std::string& data)> DataCallback;
22
23   typedef base::Callback<void(const std::string& public_key,
24                               const std::string& private_key)>
25       KeyPairCallback;
26
27   virtual ~EasyUnlockPrivateCryptoDelegate() {}
28
29   // Creates platform specific delegate instance. Non Chrome OS implementations
30   // currently do nothing but invoke callbacks with empty data.
31   static scoped_ptr<EasyUnlockPrivateCryptoDelegate> Create();
32
33   // See chromeos/dbus/easy_unlock_client.h for info on these methods.
34   virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
35   virtual void PerformECDHKeyAgreement(const std::string& private_key,
36                                        const std::string& public_key,
37                                        const DataCallback& callback) = 0;
38   virtual void CreateSecureMessage(
39       const std::string& payload,
40       const std::string& secret_key,
41       const std::string& associated_data,
42       const std::string& public_metadata,
43       const std::string& verification_key_id,
44       easy_unlock_private::EncryptionType encryption_type,
45       easy_unlock_private::SignatureType signature_type,
46       const DataCallback& callback) = 0;
47   virtual void UnwrapSecureMessage(
48       const std::string& message,
49       const std::string& secret_key,
50       const std::string& associated_data,
51       easy_unlock_private::EncryptionType encryption_type,
52       easy_unlock_private::SignatureType signature_type,
53       const DataCallback& callback) = 0;
54 };
55
56 }  // namespace api
57 }  // namespace extensions
58
59 #endif  // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_