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

Side by Side Diff: net/base/x509_certificate.cc

Issue 1417003: Revert due to compile failures... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « net/base/x509_certificate.h ('k') | net/base/x509_certificate_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/x509_certificate.h" 5 #include "net/base/x509_certificate.h"
6 6
7 #if defined(OS_MACOSX) 7 #if defined(USE_NSS)
8 #include <Security/Security.h>
9 #elif defined(USE_NSS)
10 #include <cert.h> 8 #include <cert.h>
11 #endif 9 #endif
12 10
13 #include "base/histogram.h" 11 #include "base/histogram.h"
14 #include "base/logging.h" 12 #include "base/logging.h"
15 #include "base/time.h" 13 #include "base/time.h"
16 14
17 namespace net { 15 namespace net {
18 16
19 namespace { 17 namespace {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 return a->derCert.len == b->derCert.len && 49 return a->derCert.len == b->derCert.len &&
52 memcmp(a->derCert.data, b->derCert.data, a->derCert.len) == 0; 50 memcmp(a->derCert.data, b->derCert.data, a->derCert.len) == 0;
53 #else 51 #else
54 // TODO(snej): not implemented 52 // TODO(snej): not implemented
55 UNREACHED(); 53 UNREACHED();
56 return false; 54 return false;
57 #endif 55 #endif
58 } 56 }
59 57
60 bool X509Certificate::FingerprintLessThan::operator()( 58 bool X509Certificate::FingerprintLessThan::operator()(
61 const SHA1Fingerprint& lhs, 59 const Fingerprint& lhs,
62 const SHA1Fingerprint& rhs) const { 60 const Fingerprint& rhs) const {
63 for (size_t i = 0; i < sizeof(lhs.data); ++i) { 61 for (size_t i = 0; i < sizeof(lhs.data); ++i) {
64 if (lhs.data[i] < rhs.data[i]) 62 if (lhs.data[i] < rhs.data[i])
65 return true; 63 return true;
66 if (lhs.data[i] > rhs.data[i]) 64 if (lhs.data[i] > rhs.data[i])
67 return false; 65 return false;
68 } 66 }
69 return false; 67 return false;
70 } 68 }
71 69
72 bool X509Certificate::LessThan::operator()(X509Certificate* lhs, 70 bool X509Certificate::LessThan::operator()(X509Certificate* lhs,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 X509Certificate* X509Certificate::Cache::Find(const Fingerprint& fingerprint) { 114 X509Certificate* X509Certificate::Cache::Find(const Fingerprint& fingerprint) {
117 AutoLock lock(lock_); 115 AutoLock lock(lock_);
118 116
119 CertMap::iterator pos(cache_.find(fingerprint)); 117 CertMap::iterator pos(cache_.find(fingerprint));
120 if (pos == cache_.end()) 118 if (pos == cache_.end())
121 return NULL; 119 return NULL;
122 120
123 return pos->second; 121 return pos->second;
124 }; 122 };
125 123
124 X509Certificate::Policy::Judgment X509Certificate::Policy::Check(
125 X509Certificate* cert) const {
126 // It shouldn't matter which set we check first, but we check denied first
127 // in case something strange has happened.
128
129 if (denied_.find(cert->fingerprint()) != denied_.end()) {
130 // DCHECK that the order didn't matter.
131 DCHECK(allowed_.find(cert->fingerprint()) == allowed_.end());
132 return DENIED;
133 }
134
135 if (allowed_.find(cert->fingerprint()) != allowed_.end()) {
136 // DCHECK that the order didn't matter.
137 DCHECK(denied_.find(cert->fingerprint()) == denied_.end());
138 return ALLOWED;
139 }
140
141 // We don't have a policy for this cert.
142 return UNKNOWN;
143 }
144
145 void X509Certificate::Policy::Allow(X509Certificate* cert) {
146 // Put the cert in the allowed set and (maybe) remove it from the denied set.
147 denied_.erase(cert->fingerprint());
148 allowed_.insert(cert->fingerprint());
149 }
150
151 void X509Certificate::Policy::Deny(X509Certificate* cert) {
152 // Put the cert in the denied set and (maybe) remove it from the allowed set.
153 allowed_.erase(cert->fingerprint());
154 denied_.insert(cert->fingerprint());
155 }
156
157 bool X509Certificate::Policy::HasAllowedCert() const {
158 return !allowed_.empty();
159 }
160
161 bool X509Certificate::Policy::HasDeniedCert() const {
162 return !denied_.empty();
163 }
164
126 // static 165 // static
127 X509Certificate* X509Certificate::CreateFromHandle( 166 X509Certificate* X509Certificate::CreateFromHandle(
128 OSCertHandle cert_handle, 167 OSCertHandle cert_handle,
129 Source source, 168 Source source,
130 const OSCertHandles& intermediates) { 169 const OSCertHandles& intermediates) {
131 DCHECK(cert_handle); 170 DCHECK(cert_handle);
132 DCHECK(source != SOURCE_UNUSED); 171 DCHECK(source != SOURCE_UNUSED);
133 172
134 // Check if we already have this certificate in memory. 173 // Check if we already have this certificate in memory.
135 X509Certificate::Cache* cache = X509Certificate::Cache::GetInstance(); 174 X509Certificate::Cache* cache = X509Certificate::Cache::GetInstance();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 263
225 bool X509Certificate::HasIntermediateCertificates(const OSCertHandles& certs) { 264 bool X509Certificate::HasIntermediateCertificates(const OSCertHandles& certs) {
226 for (size_t i = 0; i < certs.size(); ++i) { 265 for (size_t i = 0; i < certs.size(); ++i) {
227 if (!HasIntermediateCertificate(certs[i])) 266 if (!HasIntermediateCertificate(certs[i]))
228 return false; 267 return false;
229 } 268 }
230 return true; 269 return true;
231 } 270 }
232 271
233 } // namespace net 272 } // namespace net
OLDNEW
« no previous file with comments | « net/base/x509_certificate.h ('k') | net/base/x509_certificate_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698