OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 5 #ifndef COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ |
6 #define COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 6 #define COMPONENTS_OWNERSHIP_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/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "components/ownership/ownership_export.h" | 16 #include "components/ownership/ownership_export.h" |
17 | 17 |
18 #if defined(USE_NSS) | 18 #if defined(USE_NSS_CERTS) |
19 struct PK11SlotInfoStr; | 19 struct PK11SlotInfoStr; |
20 typedef struct PK11SlotInfoStr PK11SlotInfo; | 20 typedef struct PK11SlotInfoStr PK11SlotInfo; |
21 #endif // defined(USE_NSS) | 21 #endif // defined(USE_NSS_CERTS) |
22 | 22 |
23 namespace crypto { | 23 namespace crypto { |
24 class RSAPrivateKey; | 24 class RSAPrivateKey; |
25 } | 25 } |
26 | 26 |
27 namespace ownership { | 27 namespace ownership { |
28 | 28 |
29 class OwnerKeyUtilTest; | 29 class OwnerKeyUtilTest; |
30 | 30 |
31 // This class is a ref-counted wrapper around a plain public key. | 31 // This class is a ref-counted wrapper around a plain public key. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 74 |
75 // This class is a helper class that allows to import public/private | 75 // This class is a helper class that allows to import public/private |
76 // parts of the owner key. | 76 // parts of the owner key. |
77 class OWNERSHIP_EXPORT OwnerKeyUtil | 77 class OWNERSHIP_EXPORT OwnerKeyUtil |
78 : public base::RefCountedThreadSafe<OwnerKeyUtil> { | 78 : public base::RefCountedThreadSafe<OwnerKeyUtil> { |
79 public: | 79 public: |
80 // Attempts to read the public key from the file system. Upon success, | 80 // Attempts to read the public key from the file system. Upon success, |
81 // returns true and populates |output|. False on failure. | 81 // returns true and populates |output|. False on failure. |
82 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0; | 82 virtual bool ImportPublicKey(std::vector<uint8>* output) = 0; |
83 | 83 |
84 #if defined(USE_NSS) | 84 #if defined(USE_NSS_CERTS) |
85 // Looks for the private key associated with |key| in the |slot| | 85 // Looks for the private key associated with |key| in the |slot| |
86 // and returns it if it can be found. Returns NULL otherwise. | 86 // and returns it if it can be found. Returns NULL otherwise. |
87 // Caller takes ownership. | 87 // Caller takes ownership. |
88 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot( | 88 virtual crypto::RSAPrivateKey* FindPrivateKeyInSlot( |
89 const std::vector<uint8>& key, | 89 const std::vector<uint8>& key, |
90 PK11SlotInfo* slot) = 0; | 90 PK11SlotInfo* slot) = 0; |
91 #endif // defined(USE_NSS) | 91 #endif // defined(USE_NSS_CERTS) |
92 | 92 |
93 // Checks whether the public key is present in the file system. | 93 // Checks whether the public key is present in the file system. |
94 virtual bool IsPublicKeyPresent() = 0; | 94 virtual bool IsPublicKeyPresent() = 0; |
95 | 95 |
96 protected: | 96 protected: |
97 virtual ~OwnerKeyUtil() {} | 97 virtual ~OwnerKeyUtil() {} |
98 | 98 |
99 private: | 99 private: |
100 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; | 100 friend class base::RefCountedThreadSafe<OwnerKeyUtil>; |
101 }; | 101 }; |
102 | 102 |
103 } // namespace ownership | 103 } // namespace ownership |
104 | 104 |
105 #endif // COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ | 105 #endif // COMPONENTS_OWNERSHIP_OWNER_KEY_UTIL_H_ |
OLD | NEW |