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

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

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

Powered by Google App Engine
This is Rietveld 408576698