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

Side by Side Diff: net/base/keygen_handler.h

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: certdb: handle GetCertTrust and IsUntrusted, failed attempt to handle SetCertTrust Created 7 years, 1 month 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
« no previous file with comments | « crypto/nss_util_internal.h ('k') | net/base/keygen_handler_nss.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 NET_BASE_KEYGEN_HANDLER_H_ 5 #ifndef NET_BASE_KEYGEN_HANDLER_H_
6 #define NET_BASE_KEYGEN_HANDLER_H_ 6 #define NET_BASE_KEYGEN_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "net/base/net_export.h" 12 #include "net/base/net_export.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 #if defined(USE_NSS) 15 #if defined(USE_NSS)
16 #include "crypto/crypto_module_blocking_password_delegate.h" 16 #include "crypto/crypto_module_blocking_password_delegate.h"
17 #include "crypto/scoped_nss_types.h"
17 #endif // defined(USE_NSS) 18 #endif // defined(USE_NSS)
18 19
19 namespace net { 20 namespace net {
20 21
21 // This class handles keypair generation for generating client 22 // This class handles keypair generation for generating client
22 // certificates via the <keygen> tag. 23 // certificates via the <keygen> tag.
23 // <http://dev.w3.org/html5/spec/Overview.html#the-keygen-element> 24 // <http://dev.w3.org/html5/spec/Overview.html#the-keygen-element>
24 // <https://developer.mozilla.org/En/HTML/HTML_Extensions/KEYGEN_Tag> 25 // <https://developer.mozilla.org/En/HTML/HTML_Extensions/KEYGEN_Tag>
25 26
26 class NET_EXPORT KeygenHandler { 27 class NET_EXPORT KeygenHandler {
27 public: 28 public:
28 // Creates a handler that will generate a key with the given key size and 29 // Creates a handler that will generate a key with the given key size and
29 // incorporate the |challenge| into the Netscape SPKAC structure. The request 30 // incorporate the |challenge| into the Netscape SPKAC structure. The request
30 // for the key originated from |url|. 31 // for the key originated from |url|.
31 KeygenHandler(int key_size_in_bits, 32 KeygenHandler(int key_size_in_bits,
32 const std::string& challenge, 33 const std::string& challenge,
33 const GURL& url); 34 const GURL& url);
34 ~KeygenHandler(); 35 ~KeygenHandler();
35 36
36 // Actually generates the key-pair and the cert request (SPKAC), and returns 37 // Actually generates the key-pair and the cert request (SPKAC), and returns
37 // a base64-encoded string suitable for use as the form value of <keygen>. 38 // a base64-encoded string suitable for use as the form value of <keygen>.
38 std::string GenKeyAndSignChallenge(); 39 std::string GenKeyAndSignChallenge();
39 40
40 // Exposed only for unit tests. 41 // Exposed only for unit tests.
41 void set_stores_key(bool store) { stores_key_ = store;} 42 void set_stores_key(bool store) { stores_key_ = store;}
42 43
43 #if defined(USE_NSS) 44 #if defined(USE_NSS)
44 // Register the password delegate to be used if the token is unauthenticated. 45 void set_key_slot(crypto::ScopedPK11Slot slot,
45 // GenKeyAndSignChallenge runs on a worker thread, so using the blocking 46 crypto::CryptoModuleBlockingPasswordDelegate* delegate);
46 // password callback is okay here.
47 // Takes ownership of the delegate.
48 void set_crypto_module_password_delegate(
49 crypto::CryptoModuleBlockingPasswordDelegate* delegate);
50 #endif // defined(USE_NSS) 47 #endif // defined(USE_NSS)
51 48
52 private: 49 private:
53 int key_size_in_bits_; // key size in bits (usually 2048) 50 int key_size_in_bits_; // key size in bits (usually 2048)
54 std::string challenge_; // challenge string sent by server 51 std::string challenge_; // challenge string sent by server
55 GURL url_; // the URL that requested the key 52 GURL url_; // the URL that requested the key
56 bool stores_key_; // should the generated key-pair be stored persistently? 53 bool stores_key_; // should the generated key-pair be stored persistently?
57 #if defined(USE_NSS) 54 #if defined(USE_NSS)
55 // The PKCS#11 token to store the key in.
56 crypto::ScopedPK11Slot slot_;
58 // The callback for requesting a password to the PKCS#11 token. 57 // The callback for requesting a password to the PKCS#11 token.
59 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> 58 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate>
60 crypto_module_password_delegate_; 59 crypto_module_password_delegate_;
61 #endif // defined(USE_NSS) 60 #endif // defined(USE_NSS)
62 }; 61 };
63 62
64 } // namespace net 63 } // namespace net
65 64
66 #endif // NET_BASE_KEYGEN_HANDLER_H_ 65 #endif // NET_BASE_KEYGEN_HANDLER_H_
OLDNEW
« no previous file with comments | « crypto/nss_util_internal.h ('k') | net/base/keygen_handler_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698