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

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

Issue 12220104: Wire up SSL client authentication for OpenSSL/Android through the net/ stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address nits Created 7 years, 9 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
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_OPENSSL_PRIVATE_KEY_STORE_H_ 5 #ifndef NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
6 #define NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_ 6 #define NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
7 7
8 #include <vector>
9
10 // Avoid including <openssl/evp.h>
11 typedef struct evp_pkey_st EVP_PKEY;
12
8 #include "base/basictypes.h" 13 #include "base/basictypes.h"
9 14 #include "base/memory/scoped_ptr.h"
10 // Avoid including <openssl/evp.h> here. 15 #include "base/synchronization/lock.h"
Ryan Sleevi 2013/02/28 00:58:35 IWYU: You don't need scoped_ptr, lock, or openssl_
digit1 2013/02/28 15:46:56 That's correct, they're no longer needed, I've fix
11 typedef struct evp_pkey_st EVP_PKEY; 16 #include "crypto/openssl_util.h"
17 #include "net/base/net_export.h"
12 18
13 class GURL; 19 class GURL;
14 20
15 namespace net { 21 namespace net {
16 22
17 // Defines an abstract store for private keys; the OpenSSL library does not 23 class X509Certificate;
18 // provide this service so it is left to individual platforms to provide it. 24
19 // 25 // OpenSSLPrivateKeyStore provides an interface for storing
20 // The contract is that the private key will be stored in an appropriate secure 26 // public/private key pairs to system storage on platforms where
21 // system location, and be available to the SSLClientSocketOpenSSL when using a 27 // OpenSSL is used.
22 // client certificate created against the associated public key for client 28 // This class shall only be used from the network thread.
23 // authentication. 29 class NET_EXPORT OpenSSLPrivateKeyStore {
24 class OpenSSLPrivateKeyStore {
25 public: 30 public:
26 // Platforms must define this factory function as appropriate. 31 // Called to permanently store a private/public key pair, generated
27 static OpenSSLPrivateKeyStore* GetInstance(); 32 // via <keygen> while visiting |url|, to an appropriate system
28 33 // location. Increments |pkey|'s reference count, so the caller is still
29 virtual ~OpenSSLPrivateKeyStore() {} 34 // responsible for calling EVP_PKEY_free on it. Note that this has
30 35 // nothing to do with the methods RecordClientCertPrivateKey() and
31 // Called to store a private key generated via <keygen> while visiting |url|. 36 // FetchClientCertPrivateKey() below.
Ryan Sleevi 2013/02/28 00:58:35 Comment needs updating.
digit1 2013/02/28 15:46:56 Done.
32 // Does not takes ownership of |pkey|, the caller reamins responsible to 37 // |url| is the corresponding server URL.
33 // EVP_PKEY_free it. (Internally, a copy maybe made or the reference count 38 // |pkey| is the key pair handle.
34 // incremented).
35 // Returns false if an error occurred whilst attempting to store the key. 39 // Returns false if an error occurred whilst attempting to store the key.
36 virtual bool StorePrivateKey(const GURL& url, EVP_PKEY* pkey) = 0; 40 static bool StoreKeyPair(const GURL& url, EVP_PKEY* pkey);
37
38 // Given a |public_key| part returns the corresponding private key, or NULL
39 // if no key found. Does NOT return ownership.
40 virtual EVP_PKEY* FetchPrivateKey(EVP_PKEY* public_key) = 0;
41
42 protected:
43 OpenSSLPrivateKeyStore() {}
44 41
45 private: 42 private:
43 OpenSSLPrivateKeyStore(); // not implemented.
44 ~OpenSSLPrivateKeyStore(); // not implemented.
46 DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStore); 45 DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStore);
47 }; 46 };
48 47
49 } // namespace net 48 } // namespace net
50 49
51 #endif // NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_ 50 #endif // NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698