blob: 9d569284c126744b4b4b66979d217a4b5c28d394 [file] [log] [blame]
Darin Petkov86964e02011-06-29 13:49:28 -07001// Copyright (c) 2011 The Chromium OS 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 SHILL_CRYPTO_PROVIDER_
6#define SHILL_CRYPTO_PROVIDER_
7
8#include <base/file_path.h>
9#include <base/memory/scoped_vector.h>
10#include <gtest/gtest_prod.h> // for FRIEND_TEST
11
Eric Shienbroodc74cf9c2012-03-02 15:00:35 -050012#include "shill/crypto_interface.h"
13
Darin Petkov86964e02011-06-29 13:49:28 -070014namespace shill {
15
Darin Petkov86964e02011-06-29 13:49:28 -070016class GLib;
17
18class CryptoProvider {
19 public:
20 explicit CryptoProvider(GLib *glib);
21
22 void Init();
23
24 // Returns |plaintext| encrypted by the highest priority available crypto
25 // module capable of performing the operation. If no module succeeds, returns
26 // |plaintext| as is.
27 std::string Encrypt(const std::string &plaintext);
28
29 // Returns |ciphertext| decrypted by the highest priority available crypto
30 // module capable of performing the operation. If no module succeeds, returns
31 // |ciphertext| as is.
32 std::string Decrypt(const std::string &ciphertext);
33
34 void set_key_matter_file(const FilePath &path) { key_matter_file_ = path; }
35
36 private:
37 FRIEND_TEST(CryptoProviderTest, Init);
38 FRIEND_TEST(KeyFileStoreTest, OpenClose);
39 typedef ScopedVector<CryptoInterface> Cryptos;
40
41 static const char kKeyMatterFile[];
42
43 GLib *glib_;
44
45 // Registered crypto modules in high to low priority order.
46 Cryptos cryptos_;
47
48 FilePath key_matter_file_;
49
50 DISALLOW_COPY_AND_ASSIGN(CryptoProvider);
51};
52
53} // namespace shill
54
55#endif // SHILL_CRYPTO_PROVIDER_