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

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

Issue 2718663005: Replace NULL with nullptr or null in webrtc/base/. (Closed)
Patch Set: Fixing Windows and formatting issues. Created 3 years, 9 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/ssladapter_unittest.cc ('k') | webrtc/base/sslidentity.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 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 #include "webrtc/base/sslfingerprint.h" 11 #include "webrtc/base/sslfingerprint.h"
12 12
13 #include <ctype.h> 13 #include <ctype.h>
14 #include <string> 14 #include <string>
15 15
16 #include "webrtc/base/helpers.h" 16 #include "webrtc/base/helpers.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/base/messagedigest.h" 18 #include "webrtc/base/messagedigest.h"
19 #include "webrtc/base/stringencode.h" 19 #include "webrtc/base/stringencode.h"
20 20
21 namespace rtc { 21 namespace rtc {
22 22
23 SSLFingerprint* SSLFingerprint::Create( 23 SSLFingerprint* SSLFingerprint::Create(
24 const std::string& algorithm, const rtc::SSLIdentity* identity) { 24 const std::string& algorithm, const rtc::SSLIdentity* identity) {
25 if (!identity) { 25 if (!identity) {
26 return NULL; 26 return nullptr;
27 } 27 }
28 28
29 return Create(algorithm, &(identity->certificate())); 29 return Create(algorithm, &(identity->certificate()));
30 } 30 }
31 31
32 SSLFingerprint* SSLFingerprint::Create( 32 SSLFingerprint* SSLFingerprint::Create(
33 const std::string& algorithm, const rtc::SSLCertificate* cert) { 33 const std::string& algorithm, const rtc::SSLCertificate* cert) {
34 uint8_t digest_val[64]; 34 uint8_t digest_val[64];
35 size_t digest_len; 35 size_t digest_len;
36 bool ret = cert->ComputeDigest( 36 bool ret = cert->ComputeDigest(
37 algorithm, digest_val, sizeof(digest_val), &digest_len); 37 algorithm, digest_val, sizeof(digest_val), &digest_len);
38 if (!ret) { 38 if (!ret) {
39 return NULL; 39 return nullptr;
40 } 40 }
41 41
42 return new SSLFingerprint(algorithm, digest_val, digest_len); 42 return new SSLFingerprint(algorithm, digest_val, digest_len);
43 } 43 }
44 44
45 SSLFingerprint* SSLFingerprint::CreateFromRfc4572( 45 SSLFingerprint* SSLFingerprint::CreateFromRfc4572(
46 const std::string& algorithm, const std::string& fingerprint) { 46 const std::string& algorithm, const std::string& fingerprint) {
47 if (algorithm.empty() || !rtc::IsFips180DigestAlgorithm(algorithm)) 47 if (algorithm.empty() || !rtc::IsFips180DigestAlgorithm(algorithm))
48 return NULL; 48 return nullptr;
49 49
50 if (fingerprint.empty()) 50 if (fingerprint.empty())
51 return NULL; 51 return nullptr;
52 52
53 size_t value_len; 53 size_t value_len;
54 char value[rtc::MessageDigest::kMaxSize]; 54 char value[rtc::MessageDigest::kMaxSize];
55 value_len = rtc::hex_decode_with_delimiter(value, sizeof(value), 55 value_len = rtc::hex_decode_with_delimiter(value, sizeof(value),
56 fingerprint.c_str(), 56 fingerprint.c_str(),
57 fingerprint.length(), 57 fingerprint.length(),
58 ':'); 58 ':');
59 if (!value_len) 59 if (!value_len)
60 return NULL; 60 return nullptr;
61 61
62 return new SSLFingerprint(algorithm, reinterpret_cast<uint8_t*>(value), 62 return new SSLFingerprint(algorithm, reinterpret_cast<uint8_t*>(value),
63 value_len); 63 value_len);
64 } 64 }
65 65
66 SSLFingerprint* SSLFingerprint::CreateFromCertificate( 66 SSLFingerprint* SSLFingerprint::CreateFromCertificate(
67 const RTCCertificate* cert) { 67 const RTCCertificate* cert) {
68 std::string digest_alg; 68 std::string digest_alg;
69 if (!cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_alg)) { 69 if (!cert->ssl_certificate().GetSignatureDigestAlgorithm(&digest_alg)) {
70 LOG(LS_ERROR) << "Failed to retrieve the certificate's digest algorithm"; 70 LOG(LS_ERROR) << "Failed to retrieve the certificate's digest algorithm";
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 std::string SSLFingerprint::ToString() const { 105 std::string SSLFingerprint::ToString() const {
106 std::string fp_str = algorithm; 106 std::string fp_str = algorithm;
107 fp_str.append(" "); 107 fp_str.append(" ");
108 fp_str.append(GetRfc4572Fingerprint()); 108 fp_str.append(GetRfc4572Fingerprint());
109 return fp_str; 109 return fp_str;
110 } 110 }
111 111
112 } // namespace rtc 112 } // namespace rtc
OLDNEW
« no previous file with comments | « webrtc/base/ssladapter_unittest.cc ('k') | webrtc/base/sslidentity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698