Home | History | Annotate | Download | only in easy_unlock_private
      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 Chrome OS. The methods read
     18 // extension function pearameters and invoke the associated EasyUnlock dbus
     19 // client methods. On non-Chrome OS platforms, the methods are stubbed out.
     20 class EasyUnlockPrivateCryptoDelegate {
     21  public:
     22   typedef base::Callback<void(const std::string& data)> DataCallback;
     23 
     24   typedef base::Callback<void(const std::string& public_key,
     25                               const std::string& private_key)>
     26       KeyPairCallback;
     27 
     28   virtual ~EasyUnlockPrivateCryptoDelegate() {}
     29 
     30   // Creates platform specific delegate instance. Non Chrome OS implementations
     31   // currently do nothing but invoke callbacks with empty data.
     32   static scoped_ptr<EasyUnlockPrivateCryptoDelegate> Create();
     33 
     34   // See chromeos/dbus/easy_unlock_client.h for info on these methods.
     35   virtual void GenerateEcP256KeyPair(const KeyPairCallback& callback) = 0;
     36   virtual void PerformECDHKeyAgreement(
     37       const easy_unlock_private::PerformECDHKeyAgreement::Params& params,
     38       const DataCallback& callback) = 0;
     39   virtual void CreateSecureMessage(
     40       const easy_unlock_private::CreateSecureMessage::Params& params,
     41       const DataCallback& callback) = 0;
     42   virtual void UnwrapSecureMessage(
     43       const easy_unlock_private::UnwrapSecureMessage::Params& params,
     44       const DataCallback& callback) = 0;
     45 };
     46 
     47 }  // namespace api
     48 }  // namespace extensions
     49 
     50 #endif  // CHROME_BROWSER_EXTENSIONS_API_EASY_UNLOCK_PRIVATE_EASY_UNLOCK_PRIVATE_CRYPTO_DELEGATE_H_
     51