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

Unified Diff: Source/platform/Crypto.h

Issue 189373010: Get rid of WTF::SHA1. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use new digest-by-chunk API and many other fixes Created 6 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: Source/platform/Crypto.h
diff --git a/Source/platform/weborigin/SecurityPolicy.h b/Source/platform/Crypto.h
similarity index 52%
copy from Source/platform/weborigin/SecurityPolicy.h
copy to Source/platform/Crypto.h
index e47e9b67d1649f148a0b3dbdeb8b80b35f1fb335..8c069fae2e20646aab36d320a5a57289cd8b79e0 100644
--- a/Source/platform/weborigin/SecurityPolicy.h
+++ b/Source/platform/Crypto.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,60 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef SecurityPolicy_h
-#define SecurityPolicy_h
+#ifndef Crypto_h
+#define Crypto_h
#include "platform/PlatformExport.h"
-#include "platform/weborigin/ReferrerPolicy.h"
-#include "wtf/text/WTFString.h"
+#include "public/platform/WebCrypto.h"
+#include "wtf/HashSet.h"
+#include "wtf/StringHasher.h"
+#include "wtf/Vector.h"
+#include "wtf/text/CString.h"
namespace WebCore {
-class KURL;
-class SecurityOrigin;
+static const size_t kMaxDigestSize = 64;
+typedef Vector<uint8_t, kMaxDigestSize> DigestValue;
-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);
+PLATFORM_EXPORT blink::WebCryptoDigestor* createDigestor(HashAlgorithm);
abarth-chromium 2014/04/01 23:46:48 PassOwnPtr<blink::WebCryptoDigestor>
jww 2014/04/02 01:11:50 Done.
+PLATFORM_EXPORT void finishDigestor(blink::WebCryptoDigestor*, 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 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::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;
};
-} // namespace WebCore
+template <>
+struct DefaultHash<WebCore::HashAlgorithm> {
+ typedef IntHash<WebCore::HashAlgorithm> Hash;
+};
+template <>
+struct HashTraits<WebCore::HashAlgorithm> : UnsignedWithZeroKeyHashTraits<WebCore::HashAlgorithm> {
+};
-#endif // SecurityPolicy_h
+} // namespace WTF
+#endif // Crypto_h

Powered by Google App Engine
This is Rietveld 408576698