Index: Source/platform/CryptoUtilities.h |
diff --git a/Source/platform/weborigin/SecurityPolicy.h b/Source/platform/CryptoUtilities.h |
similarity index 52% |
copy from Source/platform/weborigin/SecurityPolicy.h |
copy to Source/platform/CryptoUtilities.h |
index e47e9b67d1649f148a0b3dbdeb8b80b35f1fb335..73bd0d7bbba58119b6b5f56613750a42dc67b8e7 100644 |
--- a/Source/platform/weborigin/SecurityPolicy.h |
+++ b/Source/platform/CryptoUtilities.h |
@@ -1,5 +1,5 @@ |
/* |
- * Copyright (C) 2011 Google Inc. All rights reserved. |
+ * Copyright (C) 2014 Google Inc. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
@@ -26,38 +26,59 @@ |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
-#ifndef SecurityPolicy_h |
-#define SecurityPolicy_h |
+#ifndef CryptoUtilities_h |
+#define CryptoUtilities_h |
#include "platform/PlatformExport.h" |
-#include "platform/weborigin/ReferrerPolicy.h" |
-#include "wtf/text/WTFString.h" |
+#include "wtf/HashSet.h" |
+#include "wtf/StringHasher.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/CString.h" |
namespace WebCore { |
+namespace CryptoUtil { |
abarth-chromium
2014/03/12 18:59:02
I'd just drop this namespace entirely. WebCore is
jww
2014/04/01 23:29:09
Done.
|
-class KURL; |
-class SecurityOrigin; |
+static const size_t kMaxDigestSize = 64; |
+typedef Vector<uint8_t, kMaxDigestSize> DigestValue; |
eseidel
2014/03/12 06:51:23
I see, you're just typdefing to a vector directly,
jww
2014/04/01 23:29:09
Correct.
|
-class PLATFORM_EXPORT SecurityPolicy { |
-public: |
- // True if the referrer should be omitted according to the |
- // ReferrerPolicyDefault. If you intend to send a referrer header, you |
- // should use generateReferrerHeader instead. |
- static bool shouldHideReferrer(const KURL&, const String& referrer); |
+const size_t sha1HashSize = 20; |
+enum HashAlgorithm { |
+ HashAlgorithmSha1, |
+ HashAlgorithmSha256, |
+ HashAlgorithmSha384, |
+ HashAlgorithmSha512 |
+}; |
+ |
+PLATFORM_EXPORT void computeDigest(HashAlgorithm, const char* digestable, size_t length, DigestValue& digestResult); |
- // Returns the referrer modified according to the referrer policy for a |
- // navigation to a given URL. If the referrer returned is empty, the |
- // referrer header should be omitted. |
- static String generateReferrerHeader(ReferrerPolicy, const KURL&, const String& referrer); |
+} // namespace CryptoUtil |
+} // namespace WebCore |
- static void addOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains); |
- static void removeOriginAccessWhitelistEntry(const SecurityOrigin& sourceOrigin, const String& destinationProtocol, const String& destinationDomain, bool allowDestinationSubdomains); |
- static void resetOriginAccessWhitelists(); |
+namespace WTF { |
- static bool isAccessWhiteListed(const SecurityOrigin* activeOrigin, const SecurityOrigin* targetOrigin); |
- static bool isAccessToURLWhiteListed(const SecurityOrigin* activeOrigin, const KURL&); |
+struct DigestValueHash { |
+ static unsigned hash(const WebCore::CryptoUtil::DigestValue& v) |
+ { |
+ return StringHasher::computeHash(v.data(), v.size()); |
+ } |
+ static bool equal(const WebCore::CryptoUtil::DigestValue& a, const WebCore::CryptoUtil::DigestValue& b) |
+ { |
+ return a == b; |
+ }; |
+ static const bool safeToCompareToEmptyOrDeleted = true; |
+}; |
+template <> |
+struct DefaultHash<WebCore::CryptoUtil::DigestValue> { |
+ typedef DigestValueHash Hash; |
}; |
-} // namespace WebCore |
+template <> |
+struct DefaultHash<WebCore::CryptoUtil::HashAlgorithm> { |
+ typedef IntHash<WebCore::CryptoUtil::HashAlgorithm> Hash; |
+}; |
+template <> |
+struct HashTraits<WebCore::CryptoUtil::HashAlgorithm> : UnsignedWithZeroKeyHashTraits<WebCore::CryptoUtil::HashAlgorithm> { |
+}; |
-#endif // SecurityPolicy_h |
+} // namespace WTF |
+#endif // CryptoUtilities_h |