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

Side by Side Diff: webrtc/base/sslidentity.cc

Issue 2640513002: Relanding: Removing #defines previously used for building without BoringSSL/OpenSSL. (Closed)
Patch Set: Rebase Created 3 years, 11 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
« no previous file with comments | « webrtc/base/sslconfig.h ('k') | webrtc/base/sslstreamadapter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 // Handling of certificates and keypairs for SSLStreamAdapter's peer mode. 11 // Handling of certificates and keypairs for SSLStreamAdapter's peer mode.
12 #include "webrtc/base/sslidentity.h" 12 #include "webrtc/base/sslidentity.h"
13 13
14 #include <ctime> 14 #include <ctime>
15 #include <string> 15 #include <string>
16 16
17 #include "webrtc/base/base64.h" 17 #include "webrtc/base/base64.h"
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
20 #include "webrtc/base/sslconfig.h" 20 #include "webrtc/base/opensslidentity.h"
21 #include "webrtc/base/sslfingerprint.h" 21 #include "webrtc/base/sslfingerprint.h"
22 22
23 #if SSL_USE_OPENSSL
24
25 #include "webrtc/base/opensslidentity.h"
26
27 #endif // SSL_USE_OPENSSL
28
29 namespace rtc { 23 namespace rtc {
30 24
31 const char kPemTypeCertificate[] = "CERTIFICATE"; 25 const char kPemTypeCertificate[] = "CERTIFICATE";
32 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY"; 26 const char kPemTypeRsaPrivateKey[] = "RSA PRIVATE KEY";
33 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY"; 27 const char kPemTypeEcPrivateKey[] = "EC PRIVATE KEY";
34 28
35 SSLCertificateStats::SSLCertificateStats( 29 SSLCertificateStats::SSLCertificateStats(
36 std::string&& fingerprint, 30 std::string&& fingerprint,
37 std::string&& fingerprint_algorithm, 31 std::string&& fingerprint_algorithm,
38 std::string&& base64_certificate, 32 std::string&& base64_certificate,
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 200 }
207 201
208 SSLCertChain::SSLCertChain(const SSLCertificate* cert) { 202 SSLCertChain::SSLCertChain(const SSLCertificate* cert) {
209 certs_.push_back(cert->GetReference()); 203 certs_.push_back(cert->GetReference());
210 } 204 }
211 205
212 SSLCertChain::~SSLCertChain() { 206 SSLCertChain::~SSLCertChain() {
213 std::for_each(certs_.begin(), certs_.end(), DeleteCert); 207 std::for_each(certs_.begin(), certs_.end(), DeleteCert);
214 } 208 }
215 209
216 #if SSL_USE_OPENSSL
217
218 // static 210 // static
219 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) { 211 SSLCertificate* SSLCertificate::FromPEMString(const std::string& pem_string) {
220 return OpenSSLCertificate::FromPEMString(pem_string); 212 return OpenSSLCertificate::FromPEMString(pem_string);
221 } 213 }
222 214
223 // static 215 // static
224 SSLIdentity* SSLIdentity::GenerateWithExpiration(const std::string& common_name, 216 SSLIdentity* SSLIdentity::GenerateWithExpiration(const std::string& common_name,
225 const KeyParams& key_params, 217 const KeyParams& key_params,
226 time_t certificate_lifetime) { 218 time_t certificate_lifetime) {
227 return OpenSSLIdentity::GenerateWithExpiration(common_name, key_params, 219 return OpenSSLIdentity::GenerateWithExpiration(common_name, key_params,
(...skipping 25 matching lines...) Expand all
253 } 245 }
254 246
255 bool operator==(const SSLIdentity& a, const SSLIdentity& b) { 247 bool operator==(const SSLIdentity& a, const SSLIdentity& b) {
256 return static_cast<const OpenSSLIdentity&>(a) == 248 return static_cast<const OpenSSLIdentity&>(a) ==
257 static_cast<const OpenSSLIdentity&>(b); 249 static_cast<const OpenSSLIdentity&>(b);
258 } 250 }
259 bool operator!=(const SSLIdentity& a, const SSLIdentity& b) { 251 bool operator!=(const SSLIdentity& a, const SSLIdentity& b) {
260 return !(a == b); 252 return !(a == b);
261 } 253 }
262 254
263 #else // !SSL_USE_OPENSSL
264
265 #error "No SSL implementation"
266
267 #endif // SSL_USE_OPENSSL
268
269 // Read |n| bytes from ASN1 number string at *|pp| and return the numeric value. 255 // Read |n| bytes from ASN1 number string at *|pp| and return the numeric value.
270 // Update *|pp| and *|np| to reflect number of read bytes. 256 // Update *|pp| and *|np| to reflect number of read bytes.
271 static inline int ASN1ReadInt(const unsigned char** pp, size_t* np, size_t n) { 257 static inline int ASN1ReadInt(const unsigned char** pp, size_t* np, size_t n) {
272 const unsigned char* p = *pp; 258 const unsigned char* p = *pp;
273 int x = 0; 259 int x = 0;
274 for (size_t i = 0; i < n; i++) 260 for (size_t i = 0; i < n; i++)
275 x = 10 * x + p[i] - '0'; 261 x = 10 * x + p[i] - '0';
276 *pp = p + n; 262 *pp = p + n;
277 *np = *np - n; 263 *np = *np - n;
278 return x; 264 return x;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 316
331 if (bytes_left != 1) { 317 if (bytes_left != 1) {
332 // Now just Z should remain. Its existence was asserted above. 318 // Now just Z should remain. Its existence was asserted above.
333 return -1; 319 return -1;
334 } 320 }
335 321
336 return TmToSeconds(tm); 322 return TmToSeconds(tm);
337 } 323 }
338 324
339 } // namespace rtc 325 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/sslconfig.h ('k') | webrtc/base/sslstreamadapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698