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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: net/base/x509_certificate.cc
diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc
index 089bf096ff396fd10686af7250db78ef969eb105..525595bdd5733567e13abc5db20788fde6a71b3c 100644
--- a/net/base/x509_certificate.cc
+++ b/net/base/x509_certificate.cc
@@ -8,10 +8,13 @@
#include <string>
#include <vector>
+#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.
+
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram.h"
+#include "base/sha1.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/time.h"
@@ -528,4 +531,17 @@ bool X509Certificate::IsBlacklisted() const {
return false;
}
+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.
+ return memcmp(a, b, base::SHA1_LENGTH);
+}
+
+// static
+bool X509Certificate::IsSHA1HashInSortedArray(const uint8 hash[20],
+ const uint8* array,
+ 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.
+ const unsigned arraylen = bytelen / base::SHA1_LENGTH;
+ return NULL != bsearch(hash, array, arraylen, base::SHA1_LENGTH,
+ CompareSHA1Hashes);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698