OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H | |
6 #define COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H | |
7 | |
8 #include "base/macros.h" | |
9 #include "components/proximity_auth/cryptauth/secure_message_delegate.h" | |
10 | |
11 namespace proximity_auth { | |
12 | |
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 { | |
17 public: | |
18 FakeSecureMessageDelegate(); | |
19 ~FakeSecureMessageDelegate() override; | |
20 | |
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; | |
36 | |
37 // Returns the corresponding private key for the given |public_key|. | |
38 std::string GetPrivateKeyForPublicKey(const std::string& public_key); | |
39 | |
40 // Sets the next public key to be returned by GenerateKeyPair(). The | |
41 // corresponding private key will be derived from this public key. | |
42 void set_next_public_key(const std::string& public_key) { | |
43 next_public_key_ = public_key; | |
44 } | |
45 | |
46 private: | |
47 std::string next_public_key_; | |
48 | |
49 DISALLOW_COPY_AND_ASSIGN(FakeSecureMessageDelegate); | |
50 }; | |
51 | |
52 } // namespace proximity_auth | |
53 | |
54 #endif // COMPONENTS_PROXIMITY_AUTH_FAKE_SECURE_MESSAGE_DELEGATE_H | |
OLD | NEW |