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

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

Issue 270663002: Implemented profile-aware owner key loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes, rebase. Created 6 years, 7 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "net/cert/x509_util_nss.h"
16 17
17 namespace base { 18 namespace base {
18 class FilePath; 19 class FilePath;
19 } 20 }
20 21
21 namespace crypto { 22 namespace crypto {
22 class RSAPrivateKey; 23 class RSAPrivateKey;
23 } 24 }
24 25
25 namespace chromeos { 26 namespace chromeos {
26 27
27 class OwnerKeyUtilTest; 28 class OwnerKeyUtilTest;
28 29
29 class OwnerKeyUtil : public base::RefCountedThreadSafe<OwnerKeyUtil> { 30 class OwnerKeyUtil : public base::RefCountedThreadSafe<OwnerKeyUtil> {
30 public: 31 public:
31 // Creates an OwnerKeyUtil instance. 32 // Creates an OwnerKeyUtil instance.
32 static OwnerKeyUtil* Create(); 33 static OwnerKeyUtil* Create();
33 34
34 // Attempts to read the public key from the file system. 35 // Attempts to read the public key from the file system.
35 // Upon success, returns true and populates |output|. False on failure. 36 // Upon success, returns true and populates |output|. False on failure.
36 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0; 37 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0;
37 38
38 // Looks for the private key associated with |key| in the default slot, 39 // Looks for the private key associated with |key| in the default slot,
39 // and returns it if it can be found. Returns NULL otherwise. 40 // and returns it if it can be found. Returns NULL otherwise.
40 // Caller takes ownership. 41 // Caller takes ownership.
42 //
43 // TODO (ygorshenin@): this function is deprecated and should be
44 // removed, see crbug.com/372316.
41 virtual crypto::RSAPrivateKey* FindPrivateKey( 45 virtual crypto::RSAPrivateKey* FindPrivateKey(
42 const std::vector<uint8>& key) = 0; 46 const std::vector<uint8>& key) = 0;
43 47
48 // Looks for the private key associated with |key| in the |slot|
49 // and returns it if it can be found. Returns NULL otherwise.
50 // Caller takes ownership.
51 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
52 const std::vector<uint8>& key,
53 PK11SlotInfo* slot) = 0;
54
44 // Checks whether the public key is present in the file system. 55 // Checks whether the public key is present in the file system.
45 virtual bool IsPublicKeyPresent() = 0; 56 virtual bool IsPublicKeyPresent() = 0;
46 57
47 protected: 58 protected:
48 OwnerKeyUtil(); 59 OwnerKeyUtil();
49 virtual ~OwnerKeyUtil(); 60 virtual ~OwnerKeyUtil();
50 61
51 private: 62 private:
52 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; 63 friend class base::RefCountedThreadSafe<OwnerKeyUtil>;
53 64
54 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey); 65 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey);
55 }; 66 };
56 67
57 // Implementation of OwnerKeyUtil that is used in production code. 68 // Implementation of OwnerKeyUtil that is used in production code.
58 class OwnerKeyUtilImpl : public OwnerKeyUtil { 69 class OwnerKeyUtilImpl : public OwnerKeyUtil {
59 public: 70 public:
60 explicit OwnerKeyUtilImpl(const base::FilePath& public_key_file); 71 explicit OwnerKeyUtilImpl(const base::FilePath& public_key_file);
61 72
62 // OwnerKeyUtil: 73 // OwnerKeyUtil:
63 virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE; 74 virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE;
64 virtual crypto::RSAPrivateKey* FindPrivateKey( 75 virtual crypto::RSAPrivateKey* FindPrivateKey(
65 const std::vector<uint8>& key) OVERRIDE; 76 const std::vector<uint8>& key) OVERRIDE;
77 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
78 const std::vector<uint8>& key,
79 PK11SlotInfo* slot) OVERRIDE;
66 virtual bool IsPublicKeyPresent() OVERRIDE; 80 virtual bool IsPublicKeyPresent() OVERRIDE;
67 81
68 protected: 82 protected:
69 virtual ~OwnerKeyUtilImpl(); 83 virtual ~OwnerKeyUtilImpl();
70 84
71 private: 85 private:
72 // The file that holds the public key. 86 // The file that holds the public key.
73 base::FilePath key_file_; 87 base::FilePath key_file_;
74 88
75 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl); 89 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl);
76 }; 90 };
77 91
78 } // namespace chromeos 92 } // namespace chromeos
79 93
80 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 94 #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