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

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: Fixed DeviceOAuth2TokenServiceTest.* unit_tests. 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.
41 virtual crypto::RSAPrivateKey* FindPrivateKey( 42 virtual crypto::RSAPrivateKey* FindPrivateKey(
Mattias Nissler (ping if slow) 2014/05/12 08:26:43 I guess this is now deprecated and should be remov
ygorshenin1 2014/05/13 09:46:13 Done.
42 const std::vector<uint8>& key) = 0; 43 const std::vector<uint8>& key) = 0;
43 44
45 // Looks for the private key associated with |key| in the |slot|
46 // and returns it if it can be found. Returns NULL otherwise.
47 // Caller takes ownership.
48 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
49 const std::vector<uint8>& key,
50 PK11SlotInfo* slot) = 0;
51
44 // Checks whether the public key is present in the file system. 52 // Checks whether the public key is present in the file system.
45 virtual bool IsPublicKeyPresent() = 0; 53 virtual bool IsPublicKeyPresent() = 0;
46 54
47 protected: 55 protected:
48 OwnerKeyUtil(); 56 OwnerKeyUtil();
49 virtual ~OwnerKeyUtil(); 57 virtual ~OwnerKeyUtil();
50 58
51 private: 59 private:
52 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; 60 friend class base::RefCountedThreadSafe<OwnerKeyUtil>;
53 61
54 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey); 62 FRIEND_TEST_ALL_PREFIXES(OwnerKeyUtilTest, ExportImportPublicKey);
55 }; 63 };
56 64
57 // Implementation of OwnerKeyUtil that is used in production code. 65 // Implementation of OwnerKeyUtil that is used in production code.
58 class OwnerKeyUtilImpl : public OwnerKeyUtil { 66 class OwnerKeyUtilImpl : public OwnerKeyUtil {
59 public: 67 public:
60 explicit OwnerKeyUtilImpl(const base::FilePath& public_key_file); 68 explicit OwnerKeyUtilImpl(const base::FilePath& public_key_file);
61 69
62 // OwnerKeyUtil: 70 // OwnerKeyUtil:
63 virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE; 71 virtual bool ImportPublicKey(std::vector<uint8>* output) OVERRIDE;
64 virtual crypto::RSAPrivateKey* FindPrivateKey( 72 virtual crypto::RSAPrivateKey* FindPrivateKey(
65 const std::vector<uint8>& key) OVERRIDE; 73 const std::vector<uint8>& key) OVERRIDE;
74 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot(
75 const std::vector<uint8>& key,
76 PK11SlotInfo* slot) OVERRIDE;
66 virtual bool IsPublicKeyPresent() OVERRIDE; 77 virtual bool IsPublicKeyPresent() OVERRIDE;
67 78
68 protected: 79 protected:
69 virtual ~OwnerKeyUtilImpl(); 80 virtual ~OwnerKeyUtilImpl();
70 81
71 private: 82 private:
72 // The file that holds the public key. 83 // The file that holds the public key.
73 base::FilePath key_file_; 84 base::FilePath key_file_;
74 85
75 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl); 86 DISALLOW_COPY_AND_ASSIGN(OwnerKeyUtilImpl);
76 }; 87 };
77 88
78 } // namespace chromeos 89 } // namespace chromeos
79 90
80 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_ 91 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_OWNER_KEY_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698