Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef SubresourceIntegrity_h | 5 #ifndef SubresourceIntegrity_h |
| 6 #define SubresourceIntegrity_h | 6 #define SubresourceIntegrity_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/Crypto.h" | 9 #include "platform/Crypto.h" |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 static bool CheckSubresourceIntegrity(const Element&, const WTF::String& con tent, const KURL& resourceUrl, const Resource&); | 29 static bool CheckSubresourceIntegrity(const Element&, const WTF::String& con tent, const KURL& resourceUrl, const Resource&); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 // FIXME: After the merge with the Chromium repo, this should be refactored | 32 // FIXME: After the merge with the Chromium repo, this should be refactored |
| 33 // to use FRIEND_TEST in base/gtest_prod_util.h. | 33 // to use FRIEND_TEST in base/gtest_prod_util.h. |
| 34 friend class SubresourceIntegrityTest; | 34 friend class SubresourceIntegrityTest; |
| 35 friend class SubresourceIntegrityTest_Parsing_Test; | 35 friend class SubresourceIntegrityTest_Parsing_Test; |
| 36 friend class SubresourceIntegrityTest_ParseAlgorithm_Test; | 36 friend class SubresourceIntegrityTest_ParseAlgorithm_Test; |
| 37 friend class SubresourceIntegrityTest_Prioritization_Test; | |
| 37 | 38 |
| 38 enum AlgorithmParseResult { | 39 enum AlgorithmParseResult { |
| 39 AlgorithmValid, | 40 AlgorithmValid, |
| 40 AlgorithmUnparsable, | 41 AlgorithmUnparsable, |
| 41 AlgorithmUnknown | 42 AlgorithmUnknown |
| 42 }; | 43 }; |
| 43 | 44 |
| 45 enum PrioritizationResult { | |
| 46 SameStrength, | |
| 47 FirstAlgorithmIsStronger, | |
| 48 SecondAlgorithmIsStronger | |
| 49 }; | |
| 50 | |
| 44 struct IntegrityMetadata { | 51 struct IntegrityMetadata { |
| 45 WTF::String digest; | 52 WTF::String digest; |
| 46 HashAlgorithm algorithm; | 53 HashAlgorithm algorithm; |
| 47 }; | 54 }; |
| 48 | 55 |
| 56 static PrioritizationResult getPrioritizedHashFunction(HashAlgorithm, HashAl gorithm); | |
|
Mike West
2015/06/03 09:13:33
Why not return the stronger `HashAlgorithm`? The "
jww
2015/06/03 19:26:56
See other comments for details, but I've changed i
| |
| 49 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, const UChar* end, HashAlgorithm&); | 57 static AlgorithmParseResult parseAlgorithm(const UChar*& begin, const UChar* end, HashAlgorithm&); |
| 50 static bool parseDigest(const UChar*& begin, const UChar* end, String& diges t); | 58 static bool parseDigest(const UChar*& begin, const UChar* end, String& diges t); |
| 51 | 59 |
| 52 static IntegrityParseResult parseIntegrityAttribute(const WTF::String& attri bute, WTF::Vector<IntegrityMetadata>& metadataList, Document&); | 60 static IntegrityParseResult parseIntegrityAttribute(const WTF::String& attri bute, WTF::Vector<IntegrityMetadata>& metadataList, Document&); |
| 53 }; | 61 }; |
| 54 | 62 |
| 55 } // namespace blink | 63 } // namespace blink |
| 56 | 64 |
| 57 #endif | 65 #endif |
| OLD | NEW |