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

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

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