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
3 // found in the LICENSE file.
5 #ifndef NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
6 #define NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_
8 #include "base/basictypes.h"
10 typedef struct evp_pkey_st EVP_PKEY
;
16 // Defines an abstract store for private keys; the OpenSSL library does not
17 // provide this service so it is left to individual platforms to provide it.
19 // The contract is that the private key will be stored in an appropriate secure
20 // system location, and be available to the SSLClientSocketOpenSSL when using a
21 // client certificate created against the associated public key for client
23 class OpenSSLPrivateKeyStore
{
25 // Platforms must define this factory function as appropriate.
26 static OpenSSLPrivateKeyStore
* GetInstance();
28 virtual ~OpenSSLPrivateKeyStore() {}
30 // Called to store a private key generated via <keygen> while visiting |url|.
31 // Does not takes ownership of |pkey|, the caller reamins responsible to
32 // EVP_PKEY_free it. (Internally, a copy maybe made or the reference count
34 // Returns false if an error occurred whilst attempting to store the key.
35 virtual bool StorePrivateKey(const GURL
& url
, EVP_PKEY
* pkey
) = 0;
37 // Given a |public_key| part returns the corresponding private key, or NULL
38 // if no key found. Does NOT return ownership.
39 virtual EVP_PKEY
* FetchPrivateKey(EVP_PKEY
* public_key
) = 0;
42 OpenSSLPrivateKeyStore() {}
45 DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStore
);
50 #endif // NET_BASE_OPENSSL_PRIVATE_KEY_STORE_H_