chromium/chromeos/ash/components/dbus/chaps/fake_chaps_client.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_DBUS_CHAPS_FAKE_CHAPS_CLIENT_H_
#define CHROMEOS_ASH_COMPONENTS_DBUS_CHAPS_FAKE_CHAPS_CLIENT_H_

#include <stdint.h>

#include <vector>

#include "base/component_export.h"
#include "chromeos/ash/components/dbus/chaps/chaps_client.h"

namespace ash {

// A fake version of ChapsClient. Right now always returns an error for all
// requests. Can be updated to better simulate replies from the real Chaps if
// needed.
class COMPONENT_EXPORT(ASH_DBUS_CHAPS) FakeChapsClient : public ChapsClient {
  // Implements ChapsClient.
  void GetSlotList(bool token_present, ArrayOfUint64Callback callback) override;
  void GetMechanismList(uint64_t slot_id,
                        ArrayOfUint64Callback callback) override;
  void OpenSession(uint64_t slot_id,
                   uint64_t flags,
                   Uint64Callback callback) override;
  void CloseSession(uint64_t session_id, ResultCodeCallback callback) override;
  void CreateObject(uint64_t session_id,
                    const std::vector<uint8_t>& attributes,
                    Uint64Callback callback) override;
  void DestroyObject(uint64_t session_id,
                     uint64_t object_handle,
                     ResultCodeCallback callback) override;
  void GetAttributeValue(uint64_t session_id,
                         uint64_t object_handle,
                         const std::vector<uint8_t>& attributes_query,
                         GetAttributeValueCallback callback) override;
  void SetAttributeValue(uint64_t session_id,
                         uint64_t object_handle,
                         const std::vector<uint8_t>& attributes,
                         ResultCodeCallback callback) override;
  void FindObjectsInit(uint64_t session_id,
                       const std::vector<uint8_t>& attributes,
                       ResultCodeCallback callback) override;
  void FindObjects(uint64_t session_id,
                   uint64_t max_object_count,
                   ArrayOfUint64Callback callback) override;
  void FindObjectsFinal(uint64_t session_id,
                        ResultCodeCallback callback) override;
  void EncryptInit(uint64_t session_id,
                   uint64_t mechanism_type,
                   const std::vector<uint8_t>& mechanism_parameter,
                   uint64_t key_handle,
                   ResultCodeCallback callback) override;
  void Encrypt(uint64_t session_id,
               const std::vector<uint8_t>& data,
               uint64_t max_out_length,
               DataCallback callback) override;
  void DecryptInit(uint64_t session_id,
                   uint64_t mechanism_type,
                   const std::vector<uint8_t>& mechanism_parameter,
                   uint64_t key_handle,
                   ResultCodeCallback callback) override;
  void Decrypt(uint64_t session_id,
               const std::vector<uint8_t>& data,
               uint64_t max_out_length,
               DataCallback callback) override;
  void SignInit(uint64_t session_id,
                uint64_t mechanism_type,
                const std::vector<uint8_t>& mechanism_parameter,
                uint64_t key_handle,
                ResultCodeCallback callback) override;
  void Sign(uint64_t session_id,
            const std::vector<uint8_t>& data,
            uint64_t max_out_length,
            DataCallback callback) override;
  void GenerateKeyPair(uint64_t session_id,
                       uint64_t mechanism_type,
                       const std::vector<uint8_t>& mechanism_parameter,
                       const std::vector<uint8_t>& public_attributes,
                       const std::vector<uint8_t>& private_attributes,
                       GenerateKeyPairCallback callback) override;
  void WrapKey(uint64_t session_id,
               uint64_t mechanism_type,
               const std::vector<uint8_t>& mechanism_parameter,
               uint64_t wrapping_key_handle,
               uint64_t key_handle,
               uint64_t max_out_length,
               DataCallback callback) override;
  void UnwrapKey(uint64_t session_id,
                 uint64_t mechanism_type,
                 const std::vector<uint8_t>& mechanism_parameter,
                 uint64_t wrapping_key_handle,
                 const std::vector<uint8_t>& wrapped_key,
                 const std::vector<uint8_t>& attributes,
                 Uint64Callback callback) override;
  void DeriveKey(uint64_t session_id,
                 uint64_t mechanism_type,
                 const std::vector<uint8_t>& mechanism_parameter,
                 uint64_t base_key_handle,
                 const std::vector<uint8_t>& attributes,
                 Uint64Callback callback) override;
};

}  // namespace ash

#endif  // CHROMEOS_ASH_COMPONENTS_DBUS_CHAPS_FAKE_CHAPS_CLIENT_H_