1 // Copyright 2015 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.
5 #ifndef COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H
6 #define COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H
8 #include "base/macros.h"
9 #include "components/proximity_auth/cryptauth/secure_message_delegate.h"
11 namespace proximity_auth
{
13 // Fake implementation of SecureMessageDelegate used in tests.
14 // For clarity in tests, all functions in this delegate will invoke their
15 // callback with the result before returning.
16 class FakeSecureMessageDelegate
: public SecureMessageDelegate
{
18 FakeSecureMessageDelegate();
19 ~FakeSecureMessageDelegate() override
;
21 // SecureMessageDelegate:
22 void GenerateKeyPair(const GenerateKeyPairCallback
& callback
) override
;
23 void DeriveKey(const std::string
& private_key
,
24 const std::string
& public_key
,
25 const DeriveKeyCallback
& callback
) override
;
26 void CreateSecureMessage(
27 const std::string
& payload
,
28 const std::string
& key
,
29 const CreateOptions
& create_options
,
30 const CreateSecureMessageCallback
& callback
) override
;
31 void UnwrapSecureMessage(
32 const std::string
& serialized_message
,
33 const std::string
& key
,
34 const UnwrapOptions
& unwrap_options
,
35 const UnwrapSecureMessageCallback
& callback
) override
;
37 // Sets the next public key to be returned by GenerateKeyPair(). The
38 // corresponding private key will be derived from this public key.
39 void set_next_public_key(const std::string
& public_key
) {
40 next_public_key_
= public_key
;
44 std::string next_public_key_
;
46 DISALLOW_COPY_AND_ASSIGN(FakeSecureMessageDelegate
);
49 } // namespace proximity_auth
51 #endif // COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H