summaryrefslogtreecommitdiffstats
path: root/net/base
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 21:15:27 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-28 21:15:27 +0000
commitb13b9bdddf305f4992a97508a757600f40232faa (patch)
tree0649e1056f6e6c67921c7104ec406665c5c2b224 /net/base
parent927c151d93c1d458dc8e92e4b4dcb07874a0c436 (diff)
downloadchromium_src-b13b9bdddf305f4992a97508a757600f40232faa.zip
chromium_src-b13b9bdddf305f4992a97508a757600f40232faa.tar.gz
chromium_src-b13b9bdddf305f4992a97508a757600f40232faa.tar.bz2
Update SHA1_LENGTH -> kSHA1Length to match previous change to SHA256_LENGTH.
(I didn't try and understand or fix why kSHA1Length is in base:: while kSHA256Length is in crypto::.) BUG=92247 TEST=compiles Review URL: http://codereview.chromium.org/7972024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103179 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r--net/base/dnssec_chain_verifier.cc2
-rw-r--r--net/base/transport_security_state.cc7
-rw-r--r--net/base/x509_certificate.cc12
-rw-r--r--net/base/x509_certificate_unittest.cc9
4 files changed, 12 insertions, 18 deletions
diff --git a/net/base/dnssec_chain_verifier.cc b/net/base/dnssec_chain_verifier.cc
index 7be383d..5104545 100644
--- a/net/base/dnssec_chain_verifier.cc
+++ b/net/base/dnssec_chain_verifier.cc
@@ -437,7 +437,7 @@ bool DNSSECChainVerifier::DigestKey(base::StringPiece* out,
if (digest_type == kDNSSEC_SHA1) {
temp = base::SHA1HashString(input);
digest = reinterpret_cast<const uint8*>(temp.data());
- digest_len = base::SHA1_LENGTH;
+ digest_len = base::kSHA1Length;
} else if (digest_type == kDNSSEC_SHA256) {
crypto::SHA256HashString(input, temp2, sizeof(temp2));
digest = temp2;
diff --git a/net/base/transport_security_state.cc b/net/base/transport_security_state.cc
index fd6f11b..31454fd 100644
--- a/net/base/transport_security_state.cc
+++ b/net/base/transport_security_state.cc
@@ -11,11 +11,6 @@
#include <keyhi.h>
#include <pk11pub.h>
-// NSS leaks #defines from its headers which will upset base/sha1.h.
-#if defined(SHA1_LENGTH)
-#undef SHA1_LENGTH
-#endif
-
#include "base/base64.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
@@ -597,7 +592,7 @@ static bool AddHash(const std::string& type_and_base64,
if (type_and_base64.find("sha1/") == 0 &&
base::Base64Decode(type_and_base64.substr(5, type_and_base64.size() - 5),
&hash_str) &&
- hash_str.size() == base::SHA1_LENGTH) {
+ hash_str.size() == base::kSHA1Length) {
SHA1Fingerprint hash;
memcpy(hash.data, hash_str.data(), sizeof(hash.data));
out->push_back(hash);
diff --git a/net/base/x509_certificate.cc b/net/base/x509_certificate.cc
index 6e08d8e..881adb8 100644
--- a/net/base/x509_certificate.cc
+++ b/net/base/x509_certificate.cc
@@ -187,7 +187,7 @@ void X509CertificateCache::Remove(X509Certificate::OSCertHandle cert_handle) {
// CompareSHA1Hashes is a helper function for using bsearch() with an array of
// SHA1 hashes.
int CompareSHA1Hashes(const void* a, const void* b) {
- return memcmp(a, b, base::SHA1_LENGTH);
+ return memcmp(a, b, base::kSHA1Length);
}
// Utility to split |src| on the first occurrence of |c|, if any. |right| will
@@ -959,7 +959,7 @@ bool X509Certificate::IsBlacklisted() const {
bool X509Certificate::IsPublicKeyBlacklisted(
const std::vector<SHA1Fingerprint>& public_key_hashes) {
static const unsigned kNumHashes = 5;
- static const uint8 kHashes[kNumHashes][base::SHA1_LENGTH] = {
+ static const uint8 kHashes[kNumHashes][base::kSHA1Length] = {
// Subject: CN=DigiNotar Root CA
// Issuer: CN=Entrust.net x2 and self-signed
{0x41, 0x0f, 0x36, 0x36, 0x32, 0x58, 0xf3, 0x0b, 0x34, 0x7d,
@@ -985,7 +985,7 @@ bool X509Certificate::IsPublicKeyBlacklisted(
for (unsigned i = 0; i < kNumHashes; i++) {
for (std::vector<SHA1Fingerprint>::const_iterator
j = public_key_hashes.begin(); j != public_key_hashes.end(); ++j) {
- if (memcmp(j->data, kHashes[i], base::SHA1_LENGTH) == 0)
+ if (memcmp(j->data, kHashes[i], base::kSHA1Length) == 0)
return true;
}
}
@@ -997,9 +997,9 @@ bool X509Certificate::IsPublicKeyBlacklisted(
bool X509Certificate::IsSHA1HashInSortedArray(const SHA1Fingerprint& hash,
const uint8* array,
size_t array_byte_len) {
- DCHECK_EQ(0u, array_byte_len % base::SHA1_LENGTH);
- const unsigned arraylen = array_byte_len / base::SHA1_LENGTH;
- return NULL != bsearch(hash.data, array, arraylen, base::SHA1_LENGTH,
+ DCHECK_EQ(0u, array_byte_len % base::kSHA1Length);
+ const size_t arraylen = array_byte_len / base::kSHA1Length;
+ return NULL != bsearch(hash.data, array, arraylen, base::kSHA1Length,
CompareSHA1Hashes);
}
diff --git a/net/base/x509_certificate_unittest.cc b/net/base/x509_certificate_unittest.cc
index 6bf9146..ca6cfa6 100644
--- a/net/base/x509_certificate_unittest.cc
+++ b/net/base/x509_certificate_unittest.cc
@@ -37,7 +37,6 @@
#endif
using base::HexEncode;
-using base::SHA1_LENGTH;
using base::Time;
namespace net {
@@ -613,7 +612,7 @@ TEST(X509CertificateTest, ExtractSPKIFromDERCert) {
base::StringPiece spkiBytes;
EXPECT_TRUE(asn1::ExtractSPKIFromDERCert(derBytes, &spkiBytes));
- uint8 hash[base::SHA1_LENGTH];
+ uint8 hash[base::kSHA1Length];
base::SHA1HashBytes(reinterpret_cast<const uint8*>(spkiBytes.data()),
spkiBytes.size(), hash);
@@ -668,10 +667,10 @@ TEST(X509CertificateTest, PublicKeyHashes) {
EXPECT_EQ(OK, error);
EXPECT_EQ(0U, verify_result.cert_status);
ASSERT_LE(2u, verify_result.public_key_hashes.size());
- EXPECT_EQ(HexEncode(nistSPKIHash, base::SHA1_LENGTH),
- HexEncode(verify_result.public_key_hashes[0].data, SHA1_LENGTH));
+ EXPECT_EQ(HexEncode(nistSPKIHash, base::kSHA1Length),
+ HexEncode(verify_result.public_key_hashes[0].data, base::kSHA1Length));
EXPECT_EQ("83244223D6CBF0A26FC7DE27CEBCA4BDA32612AD",
- HexEncode(verify_result.public_key_hashes[1].data, SHA1_LENGTH));
+ HexEncode(verify_result.public_key_hashes[1].data, base::kSHA1Length));
TestRootCerts::GetInstance()->Clear();
}