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

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

Issue 6793041: net: add ability to distinguish user-added root CAs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ... Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include <stdlib.h>
wtc 2011/04/06 04:28:38 Nit: the C system header <stdlib.h> should be list
agl 2011/04/06 19:02:02 Done.
12
11 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
14 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/sha1.h"
15 #include "base/string_piece.h" 18 #include "base/string_piece.h"
16 #include "base/string_util.h" 19 #include "base/string_util.h"
17 #include "base/time.h" 20 #include "base/time.h"
18 #include "net/base/pem_tokenizer.h" 21 #include "net/base/pem_tokenizer.h"
19 22
20 namespace net { 23 namespace net {
21 24
22 namespace { 25 namespace {
23 26
24 // Returns true if this cert fingerprint is the null (all zero) fingerprint. 27 // Returns true if this cert fingerprint is the null (all zero) fingerprint.
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (memcmp(kSerials[i], serial_number_.data(), kSerialBytes) == 0) { 524 if (memcmp(kSerials[i], serial_number_.data(), kSerialBytes) == 0) {
522 UMA_HISTOGRAM_ENUMERATION("Net.SSLCertBlacklisted", i, kNumSerials); 525 UMA_HISTOGRAM_ENUMERATION("Net.SSLCertBlacklisted", i, kNumSerials);
523 return true; 526 return true;
524 } 527 }
525 } 528 }
526 } 529 }
527 530
528 return false; 531 return false;
529 } 532 }
530 533
534 static int CompareSHA1Hashes(const void* a, const void* b) {
wtc 2011/04/06 04:28:38 Move this file scope static function to the unname
agl 2011/04/06 19:02:02 Done.
535 return memcmp(a, b, base::SHA1_LENGTH);
536 }
537
538 // static
539 bool X509Certificate::IsSHA1HashInSortedArray(const uint8 hash[20],
540 const uint8* array,
541 unsigned bytelen) {
wtc 2011/04/06 04:28:38 The name of the third parameter should match its n
agl 2011/04/06 19:02:02 Done.
542 const unsigned arraylen = bytelen / base::SHA1_LENGTH;
543 return NULL != bsearch(hash, array, arraylen, base::SHA1_LENGTH,
544 CompareSHA1Hashes);
545 }
546
531 } // namespace net 547 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698