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

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: Fix linux_redux build. 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 <openssl/evp.h>
9
10 #include <vector>
11
8 #include "base/basictypes.h" 12 #include "base/basictypes.h"
9 13 #include "base/memory/scoped_ptr.h"
10 // Avoid including <openssl/evp.h> here. 14 #include "base/synchronization/lock.h"
11 typedef struct evp_pkey_st EVP_PKEY; 15 #include "crypto/openssl_util.h"
16 #include "net/base/net_export.h"
12 17
13 class GURL; 18 class GURL;
14 19
15 namespace net { 20 namespace net {
16 21
17 // Defines an abstract store for private keys; the OpenSSL library does not 22 class X509Certificate;
18 // provide this service so it is left to individual platforms to provide it. 23
19 // 24 // OpenSSLPrivateKeyStore provides an interface for storing
20 // The contract is that the private key will be stored in an appropriate secure 25 // public/private key pairs to system storage on platforms where
21 // system location, and be available to the SSLClientSocketOpenSSL when using a 26 // OpenSSL is used.
22 // client certificate created against the associated public key for client 27 // This class shall only be used from the network thread.
23 // authentication. 28 class NET_EXPORT OpenSSLPrivateKeyStore {
24 class OpenSSLPrivateKeyStore {
25 public: 29 public:
26 // Platforms must define this factory function as appropriate. 30 // Platforms must define this factory function as appropriate.
27 static OpenSSLPrivateKeyStore* GetInstance(); 31 static OpenSSLPrivateKeyStore* GetInstance();
28 32
29 virtual ~OpenSSLPrivateKeyStore() {} 33 // Called to permanently store a private/public key pair, generated
30 34 // via <keygen> while visiting |url|, to an appropriate system
31 // Called to store a private key generated via <keygen> while visiting |url|. 35 // location. Increments |pkey|'s reference count, so the caller is still
32 // Does not takes ownership of |pkey|, the caller reamins responsible to 36 // responsible for calling EVP_PKEY_free on it. Note that this has
33 // EVP_PKEY_free it. (Internally, a copy maybe made or the reference count 37 // nothing to do with the methods RecordClientCertPrivateKey() and
34 // incremented). 38 // FetchClientCertPrivateKey() below.
39 // |url| is the corresponding server URL.
40 // |pkey| is the key pair handle.
35 // Returns false if an error occurred whilst attempting to store the key. 41 // Returns false if an error occurred whilst attempting to store the key.
36 virtual bool StorePrivateKey(const GURL& url, EVP_PKEY* pkey) = 0; 42 virtual bool StoreKeyPair(const GURL& url, EVP_PKEY* pkey) = 0;
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 43
42 protected: 44 protected:
43 OpenSSLPrivateKeyStore() {} 45 OpenSSLPrivateKeyStore() {}
44 46
47 virtual ~OpenSSLPrivateKeyStore() {}
Ryan Sleevi 2013/02/27 01:08:20 Does this really need to be virtual with multiple
digit1 2013/02/27 10:24:27 I was just trying to make a minimally viable chang
48
45 private: 49 private:
46 DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStore); 50 DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStore);
47 }; 51 };
48 52
49 } // namespace net 53 } // namespace net
50 54
51 #endif // NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_ 55 #endif // NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698