| Index: Source/core/frame/csp/CSPSourceList.cpp
|
| diff --git a/Source/core/frame/csp/CSPSourceList.cpp b/Source/core/frame/csp/CSPSourceList.cpp
|
| index a17c5bb73cf9fdd8855017d62f68db8d6b09fdd0..988929e31e6ec533d1168e8ee8dc2ef05fec7dad 100644
|
| --- a/Source/core/frame/csp/CSPSourceList.cpp
|
| +++ b/Source/core/frame/csp/CSPSourceList.cpp
|
| @@ -7,42 +7,14 @@
|
|
|
| #include "core/frame/csp/CSPSource.h"
|
| #include "core/frame/csp/ContentSecurityPolicy.h"
|
| +#include "platform/CryptoUtilities.h"
|
| #include "platform/ParsingUtilities.h"
|
| #include "platform/weborigin/KURL.h"
|
| #include "platform/weborigin/SecurityOrigin.h"
|
| #include "wtf/HashSet.h"
|
| -#include "wtf/StringHasher.h"
|
| #include "wtf/text/Base64.h"
|
| #include "wtf/text/WTFString.h"
|
|
|
| -namespace WTF {
|
| -
|
| -struct DigestValueHash {
|
| - static unsigned hash(const WebCore::DigestValue& v)
|
| - {
|
| - return StringHasher::computeHash(v.data(), v.size());
|
| - }
|
| - static bool equal(const WebCore::DigestValue& a, const WebCore::DigestValue& b)
|
| - {
|
| - return a == b;
|
| - };
|
| - static const bool safeToCompareToEmptyOrDeleted = true;
|
| -};
|
| -template <>
|
| -struct DefaultHash<WebCore::DigestValue> {
|
| - typedef DigestValueHash Hash;
|
| -};
|
| -
|
| -template <>
|
| -struct DefaultHash<WebCore::ContentSecurityPolicyHashAlgorithm> {
|
| - typedef IntHash<WebCore::ContentSecurityPolicyHashAlgorithm> Hash;
|
| -};
|
| -template <>
|
| -struct HashTraits<WebCore::ContentSecurityPolicyHashAlgorithm> : UnsignedWithZeroKeyHashTraits<WebCore::ContentSecurityPolicyHashAlgorithm> {
|
| -};
|
| -
|
| -} // namespace WTF
|
| -
|
| namespace WebCore {
|
|
|
| static bool isSourceListNone(const UChar* begin, const UChar* end)
|
| @@ -197,7 +169,7 @@ bool CSPSourceList::parseSource(const UChar* begin, const UChar* end, String& sc
|
| return true;
|
| }
|
|
|
| - DigestValue hash;
|
| + CryptoUtil::DigestValue hash;
|
| ContentSecurityPolicyHashAlgorithm algorithm = ContentSecurityPolicyHashAlgorithmNone;
|
| if (!parseHash(begin, end, hash, algorithm))
|
| return false;
|
| @@ -309,7 +281,7 @@ bool CSPSourceList::parseNonce(const UChar* begin, const UChar* end, String& non
|
| // hash-algorithm = "sha1" / "sha256" / "sha384" / "sha512"
|
| // hash-value = 1*( ALPHA / DIGIT / "+" / "/" / "=" )
|
| //
|
| -bool CSPSourceList::parseHash(const UChar* begin, const UChar* end, DigestValue& hash, ContentSecurityPolicyHashAlgorithm& hashAlgorithm)
|
| +bool CSPSourceList::parseHash(const UChar* begin, const UChar* end, CryptoUtil::DigestValue& hash, ContentSecurityPolicyHashAlgorithm& hashAlgorithm)
|
| {
|
| // Any additions or subtractions from this struct should also modify the
|
| // respective entries in the kAlgorithmMap array in checkDigest().
|
| @@ -358,7 +330,7 @@ bool CSPSourceList::parseHash(const UChar* begin, const UChar* end, DigestValue&
|
|
|
| Vector<char> hashVector;
|
| base64Decode(hashBegin, position - hashBegin, hashVector);
|
| - if (hashVector.size() > kMaxDigestSize)
|
| + if (hashVector.size() > CryptoUtil::kMaxDigestSize)
|
| return false;
|
| hash.append(reinterpret_cast<uint8_t*>(hashVector.data()), hashVector.size());
|
| return true;
|
| @@ -506,7 +478,7 @@ void CSPSourceList::addSourceNonce(const String& nonce)
|
| m_nonces.add(nonce);
|
| }
|
|
|
| -void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algorithm, const DigestValue& hash)
|
| +void CSPSourceList::addSourceHash(const ContentSecurityPolicyHashAlgorithm& algorithm, const CryptoUtil::DigestValue& hash)
|
| {
|
| m_hashes.add(CSPHashValue(algorithm, hash));
|
| m_hashAlgorithmsUsed |= algorithm;
|
|
|