Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: chrome/browser/chromeos/settings/owner_key_util.h

Issue 10828032: Add DeviceSettingsService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/file_path.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h"
16
17 class FilePath;
18
19 namespace crypto {
20 class RSAPrivateKey;
21 }
22
23 namespace chromeos {
24
25 class OwnerKeyUtilTest;
26
27 class OwnerKeyUtil : public base::RefCounted<OwnerKeyUtil> {
28 public:
29 // Creates an OwnerKeyUtil instance.
30 static OwnerKeyUtil* Create();
31
32 // Attempts to read the public key from the file system.
33 // Upon success, returns true and populates |output|. False on failure.
34 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0;
35
36 // Looks for the private key associated with |key| in the default slot,
37 // and returns it if it can be found. Returns NULL otherwise.
38 // Caller takes ownership.
39 virtual crypto::RSAPrivateKey* FindPrivateKey(
40 const std::vector<uint8>& key) = 0;
41
42 // Checks whether the public key is present in the file system.
43 virtual bool IsPublicKeyPresent() = 0;
44
45 protected:
46 OwnerKeyUtil();
47 virtual ~OwnerKeyUtil();
48
49 private:
50 friend class base::RefCounted<OwnerKeyUtil>;
51
52 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey);
53 };
54
55 // Implementation of OwnerKeyUtil that is used in production code.
56 class OwnerKeyUtilImpl : public OwnerKeyUtil {
57 public:
58 // The file outside the owner's encrypted home directory where her
59 // key will live.
60 static const char kOwnerKeyFile[];
61
62 explicit OwnerKeyUtilImpl(const FilePath& public_key_file);
63
64 // OwnerKeyUtil:
65 virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE;
66 virtual crypto::RSAPrivateKey* FindPrivateKey(
67 const std::vector<uint8>& key) OVERRIDE;
68 virtual bool IsPublicKeyPresent() OVERRIDE;
69
70 protected:
71 virtual ~OwnerKeyUtilImpl();
72
73 private:
74 // The file that holds the public key.
75 FilePath key_file_;
76
77 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl);
78 };
79
80 } // namespace chromeos
81
82 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/settings/mock_owner_key_util.cc ('k') | chrome/browser/chromeos/settings/owner_key_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698