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

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

Issue 384413004: Remove default key slot from KeygenHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing android_webview. Created 6 years, 5 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) 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/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "net/base/net_export.h" 13 #include "net/base/net_export.h"
14 #include "url/gurl.h" 14 #include "url/gurl.h"
15 15
16 #if defined(USE_NSS)
17 #include "crypto/scoped_nss_types.h"
18 #endif
19
16 namespace crypto { 20 namespace crypto {
17 class NSSCryptoModuleDelegate; 21 class CryptoModuleBlockingPasswordDelegate;
18 } 22 }
19 23
20 namespace net { 24 namespace net {
21 25
22 // This class handles keypair generation for generating client 26 // This class handles keypair generation for generating client
23 // certificates via the <keygen> tag. 27 // certificates via the <keygen> tag.
24 // <http://dev.w3.org/html5/spec/Overview.html#the-keygen-element> 28 // <http://dev.w3.org/html5/spec/Overview.html#the-keygen-element>
25 // <https://developer.mozilla.org/En/HTML/HTML_Extensions/KEYGEN_Tag> 29 // <https://developer.mozilla.org/En/HTML/HTML_Extensions/KEYGEN_Tag>
26 30
27 class NET_EXPORT KeygenHandler { 31 class NET_EXPORT KeygenHandler {
28 public: 32 public:
29 // Creates a handler that will generate a key with the given key size and 33 // Creates a handler that will generate a key with the given key size and
30 // incorporate the |challenge| into the Netscape SPKAC structure. The request 34 // incorporate the |challenge| into the Netscape SPKAC structure. The request
31 // for the key originated from |url|. 35 // for the key originated from |url|.
32 KeygenHandler(int key_size_in_bits, 36 KeygenHandler(int key_size_in_bits,
33 const std::string& challenge, 37 const std::string& challenge,
34 const GURL& url); 38 const GURL& url);
35 ~KeygenHandler(); 39 ~KeygenHandler();
36 40
37 // Actually generates the key-pair and the cert request (SPKAC), and returns 41 // Actually generates the key-pair and the cert request (SPKAC), and returns
38 // a base64-encoded string suitable for use as the form value of <keygen>. 42 // a base64-encoded string suitable for use as the form value of <keygen>.
39 std::string GenKeyAndSignChallenge(); 43 std::string GenKeyAndSignChallenge();
40 44
41 // Exposed only for unit tests. 45 // Exposed only for unit tests.
42 void set_stores_key(bool store) { stores_key_ = store;} 46 void set_stores_key(bool store) { stores_key_ = store;}
43 47
44 #if defined(USE_NSS) 48 #if defined(USE_NSS)
49 // Sets the key slot in which new key pairs will be generated.
50 void set_key_slot(crypto::ScopedPK11Slot slot);
51
45 // Register the delegate to be used to get the token to store the key in, and 52 // Register the delegate to be used to get the token to store the key in, and
46 // to get the password if the token is unauthenticated. 53 // to get the password if the token is unauthenticated.
47 // GenKeyAndSignChallenge runs on a worker thread, so using a blocking 54 // GenKeyAndSignChallenge runs on a worker thread, so using a blocking
48 // password callback is okay here. 55 // password callback is okay here.
Ryan Sleevi 2014/07/15 21:22:33 This comment is out of date.
49 void set_crypto_module_delegate( 56 void set_crypto_module_delegate(
50 scoped_ptr<crypto::NSSCryptoModuleDelegate> delegate); 57 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate> delegate);
51 #endif // defined(USE_NSS) 58 #endif // defined(USE_NSS)
52 59
53 private: 60 private:
54 int key_size_in_bits_; // key size in bits (usually 2048) 61 int key_size_in_bits_; // key size in bits (usually 2048)
55 std::string challenge_; // challenge string sent by server 62 std::string challenge_; // challenge string sent by server
56 GURL url_; // the URL that requested the key 63 GURL url_; // the URL that requested the key
57 bool stores_key_; // should the generated key-pair be stored persistently? 64 bool stores_key_; // should the generated key-pair be stored persistently?
58 #if defined(USE_NSS) 65 #if defined(USE_NSS)
66 crypto::ScopedPK11Slot slot_;
67
59 // The callback for requesting a password to the PKCS#11 token. 68 // The callback for requesting a password to the PKCS#11 token.
60 scoped_ptr<crypto::NSSCryptoModuleDelegate> crypto_module_delegate_; 69 scoped_ptr<crypto::CryptoModuleBlockingPasswordDelegate>
70 crypto_module_delegate_;
61 #endif // defined(USE_NSS) 71 #endif // defined(USE_NSS)
62 }; 72 };
63 73
64 } // namespace net 74 } // namespace net
65 75
66 #endif // NET_BASE_KEYGEN_HANDLER_H_ 76 #endif // NET_BASE_KEYGEN_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698