OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 ENTD_PKCS11_H_ | 5 #ifndef ENTD_PKCS11_H_ |
6 #define ENTD_PKCS11_H_ | 6 #define ENTD_PKCS11_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/scoped_ptr.h> | 12 #include <base/scoped_ptr.h> |
13 #include <chromeos/utility.h> | 13 #include <chromeos/utility.h> |
14 #include <v8.h> | 14 #include <v8.h> |
15 | 15 |
16 #include "entd/js_object_wrapper.h" | 16 #include "entd/js_object_wrapper.h" |
17 | 17 |
18 namespace entd { | 18 namespace entd { |
19 | 19 |
20 class Certificate; | 20 class Certificate; |
21 class CSR; | 21 class CSR; |
22 class Pkcs11CertificateHandler; | 22 class Pkcs11CertificateHandler; |
23 class Pkcs11SlotHandler; | 23 class Pkcs11SlotHandler; |
| 24 class SlotObject; |
24 | 25 |
25 // Implementation class for interfacing with pkcs11 devices, | 26 // Implementation class for interfacing with pkcs11 devices, |
26 // including generation of Certificate Service Requests (CSR) | 27 // including generation of Certificate Service Requests (CSR) |
27 // with a hidden private key (e.g. stored in a TPM), and | 28 // with a hidden private key (e.g. stored in a TPM), and |
28 // storage of encrypted Certificates in a device associated | 29 // storage of encrypted Certificates in a device associated |
29 // with a public/private key pair. | 30 // with a public/private key pair. |
30 | 31 |
31 | 32 |
32 // Pure Interface class for defining PKCS11 slot handlers | 33 // Pure Interface class for defining PKCS11 slot handlers |
33 class Pkcs11SlotHandler { | 34 class Pkcs11SlotHandler { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 bool InitializeOpenCryptoki(const std::string& test_cert, | 102 bool InitializeOpenCryptoki(const std::string& test_cert, |
102 const std::string& engine); | 103 const std::string& engine); |
103 // Call this *instead of* Initialize() to use openssl to generate keys | 104 // Call this *instead of* Initialize() to use openssl to generate keys |
104 // and to store the private key in the tpm (like glaptop does) | 105 // and to store the private key in the tpm (like glaptop does) |
105 bool InitializeGLaptop(const std::string& test_cert); | 106 bool InitializeGLaptop(const std::string& test_cert); |
106 // Call this *instead of* Initialize() to use openssl without opencryptoki | 107 // Call this *instead of* Initialize() to use openssl without opencryptoki |
107 bool InitializeOpenSSL(const std::string& test_cert); | 108 bool InitializeOpenSSL(const std::string& test_cert); |
108 // Call this *instead of* Initialize() to use local files | 109 // Call this *instead of* Initialize() to use local files |
109 bool InitializeLocalFiles(const std::string& csr, const std::string& cert); | 110 bool InitializeLocalFiles(const std::string& csr, const std::string& cert); |
110 | 111 |
| 112 // Adds slot_object to "pkcs11.slots" |
| 113 bool AddJSSlotObject(const SlotObject* slot_object); |
| 114 |
111 // JSObjectWrapper functions | 115 // JSObjectWrapper functions |
112 static const char* GetClassName() { return "pkcs11"; } | 116 static const char* GetClassName() { return "pkcs11"; } |
113 static void SetTemplateBindings( | 117 static void SetTemplateBindings( |
114 v8::Handle<v8::ObjectTemplate> template_object); | 118 v8::Handle<v8::ObjectTemplate> template_object); |
115 | 119 |
116 // Accessors for V8 callbacks | 120 // Accessors for V8 callbacks |
117 Pkcs11CertificateHandler* certificate_handler() { | 121 Pkcs11CertificateHandler* certificate_handler() { |
118 return certificate_handler_.get(); | 122 return certificate_handler_.get(); |
119 } | 123 } |
120 Pkcs11SlotHandler* slot_handler() { | 124 Pkcs11SlotHandler* slot_handler() { |
121 return slot_handler_.get(); | 125 return slot_handler_.get(); |
122 } | 126 } |
123 | 127 |
124 private: | 128 private: |
125 scoped_ptr<Pkcs11CertificateHandler> certificate_handler_; | 129 scoped_ptr<Pkcs11CertificateHandler> certificate_handler_; |
126 scoped_ptr<Pkcs11SlotHandler> slot_handler_; | 130 scoped_ptr<Pkcs11SlotHandler> slot_handler_; |
127 | 131 |
| 132 void SetupHandlers(); |
| 133 |
128 DISALLOW_COPY_AND_ASSIGN(Pkcs11); | 134 DISALLOW_COPY_AND_ASSIGN(Pkcs11); |
129 }; | 135 }; |
130 | 136 |
131 } // namespace entd | 137 } // namespace entd |
132 | 138 |
133 #endif // ENTD_PKCS11_H_ | 139 #endif // ENTD_PKCS11_H_ |
OLD | NEW |