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

Side by Side Diff: net/base/openssl_util.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: Created 7 years, 10 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
(Empty)
1 // Copyright (c) 2013 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.
4
5 #ifndef NET_BASE_OPENSSL_UTIL_H
6 #define NET_BASE_OPENSSL_UTIL_H
7
8 #include <vector>
9
10 typedef struct evp_pkey_st EVP_PKEY;
11
12 namespace net {
13
14 class X509Certificate;
15
16 // Helper routine because EVP_PKEY_dup() doesn't exist in the
17 // version of OpenSSL used by Chromium at the moment. Avoid future
18 // name clases by using a different name too.
19 EVP_PKEY* EVP_PKEY_dup(EVP_PKEY* key);
20
21 // Helper class to hold a pair of public/private keys with
22 // appropriate ownership.
23 class OpenSSLKeyPairList {
24 public:
25 OpenSSLKeyPairList() {}
26 ~OpenSSLKeyPairList() {}
27
28 // Find the private key corresponding to a given public one.
29 // |public_key| is an EVP_PKEY holding a public key.
30 // Returns the matching EVP_PKEY holding the private key, or NULL if
31 // not found. This increases the returned key's reference count, so
32 // the caller shall call EVP_PKEY_free() on it.
33 EVP_PKEY* FindPrivateKey(EVP_PKEY* public_key);
34
35 // Add a (public/private) key pair
36 // |public_key| is the public key EVP_PKEY. Cannot be NULL.
37 // |private_key| is the private key EVP_PKEY, this can be the same
38 // object than |public_key| is it holds both a public and a private key.
39 // Cannot be NULL.
40 // Returns true on success, false otherwise.
41 // Can be called multiple times with the same data. If there is already
42 // a pair recorded for |public_key|, this returns immediately. Otherwise
43 // this increases the reference counts of both objects.
44 bool AddKeyPair(EVP_PKEY* public_key, EVP_PKEY* private_key);
45
46 private:
47 // KeyPair is an internal class used to hold a pair of private / public
48 // EVP_PKEY objects, with appropriate ownership.
49 class KeyPair {
50 public:
51 explicit KeyPair(EVP_PKEY* pub_key, EVP_PKEY* priv_key);
52 KeyPair(const KeyPair& other);
53 ~KeyPair();
54
55 EVP_PKEY* public_key_;
56 EVP_PKEY* private_key_;
57
58 private:
59 KeyPair(); // intentionally not implemented.
60 };
61
62 std::vector<KeyPair> pairs_;
63 };
64
65 // Returns the public key of a given certificate, as an OpenSSL EVP_PKEY.
66 // |cert| is the client certificate.
67 // On success, returns an EVP_PKEY* handle that must be freed by the
68 // caller with EVP_PKEY_free(). On failure, returns NULL.
69 EVP_PKEY* GetCertificatePublicKeyOpenSSL(const X509Certificate& cert);
70
71 } // namespace net
72
73 #endif // NET_BASE_OPENSSL_UTIL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698