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

Side by Side Diff: webrtc/base/opensslidentity.h

Issue 1189583002: Support generation of EC keys using P256 curve and support ECDSA certs. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 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 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 14 matching lines...) Expand all
25 namespace rtc { 25 namespace rtc {
26 26
27 // OpenSSLKeyPair encapsulates an OpenSSL EVP_PKEY* keypair object, 27 // OpenSSLKeyPair encapsulates an OpenSSL EVP_PKEY* keypair object,
28 // which is reference counted inside the OpenSSL library. 28 // which is reference counted inside the OpenSSL library.
29 class OpenSSLKeyPair { 29 class OpenSSLKeyPair {
30 public: 30 public:
31 explicit OpenSSLKeyPair(EVP_PKEY* pkey) : pkey_(pkey) { 31 explicit OpenSSLKeyPair(EVP_PKEY* pkey) : pkey_(pkey) {
32 ASSERT(pkey_ != NULL); 32 ASSERT(pkey_ != NULL);
33 } 33 }
34 34
35 static OpenSSLKeyPair* Generate(); 35 static OpenSSLKeyPair* Generate(KeyType key_type);
36 36
37 virtual ~OpenSSLKeyPair(); 37 virtual ~OpenSSLKeyPair();
38 38
39 virtual OpenSSLKeyPair* GetReference(); 39 virtual OpenSSLKeyPair* GetReference();
40 40
41 EVP_PKEY* pkey() const { return pkey_; } 41 EVP_PKEY* pkey() const { return pkey_; }
42 42
43 private: 43 private:
44 void AddReference(); 44 void AddReference();
45 45
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 X509* x509_; 93 X509* x509_;
94 94
95 DISALLOW_COPY_AND_ASSIGN(OpenSSLCertificate); 95 DISALLOW_COPY_AND_ASSIGN(OpenSSLCertificate);
96 }; 96 };
97 97
98 // Holds a keypair and certificate together, and a method to generate 98 // Holds a keypair and certificate together, and a method to generate
99 // them consistently. 99 // them consistently.
100 class OpenSSLIdentity : public SSLIdentity { 100 class OpenSSLIdentity : public SSLIdentity {
101 public: 101 public:
102 static OpenSSLIdentity* Generate(const std::string& common_name); 102 static OpenSSLIdentity* Generate(const std::string& common_name,
103 static OpenSSLIdentity* GenerateForTest(const SSLIdentityParams& params); 103 KeyType key_type);
104 static OpenSSLIdentity* GenerateForTest(const SSLIdentityParams& params,
105 KeyType key_type);
104 static SSLIdentity* FromPEMStrings(const std::string& private_key, 106 static SSLIdentity* FromPEMStrings(const std::string& private_key,
105 const std::string& certificate); 107 const std::string& certificate);
106 ~OpenSSLIdentity() override; 108 ~OpenSSLIdentity() override;
107 109
108 const OpenSSLCertificate& certificate() const override; 110 const OpenSSLCertificate& certificate() const override;
109 OpenSSLIdentity* GetReference() const override; 111 OpenSSLIdentity* GetReference() const override;
110 112
111 // Configure an SSL context object to use our key and certificate. 113 // Configure an SSL context object to use our key and certificate.
112 bool ConfigureIdentity(SSL_CTX* ctx); 114 bool ConfigureIdentity(SSL_CTX* ctx);
113 115
114 private: 116 private:
115 OpenSSLIdentity(OpenSSLKeyPair* key_pair, OpenSSLCertificate* certificate); 117 OpenSSLIdentity(OpenSSLKeyPair* key_pair, OpenSSLCertificate* certificate);
116 118
117 static OpenSSLIdentity* GenerateInternal(const SSLIdentityParams& params); 119 static OpenSSLIdentity* GenerateInternal(const SSLIdentityParams& params,
120 KeyType key_type);
118 121
119 scoped_ptr<OpenSSLKeyPair> key_pair_; 122 scoped_ptr<OpenSSLKeyPair> key_pair_;
120 scoped_ptr<OpenSSLCertificate> certificate_; 123 scoped_ptr<OpenSSLCertificate> certificate_;
121 124
122 DISALLOW_COPY_AND_ASSIGN(OpenSSLIdentity); 125 DISALLOW_COPY_AND_ASSIGN(OpenSSLIdentity);
123 }; 126 };
124 127
125 128
126 } // namespace rtc 129 } // namespace rtc
127 130
128 #endif // WEBRTC_BASE_OPENSSLIDENTITY_H_ 131 #endif // WEBRTC_BASE_OPENSSLIDENTITY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698