| 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 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/frame/SubresourceIntegrity.h" | 6 #include "core/frame/SubresourceIntegrity.h" |
| 7 | 7 |
| 8 #include "core/HTMLNames.h" | 8 #include "core/HTMLNames.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 for (size_t i = 0; i < digest1.size(); i++) { | 54 for (size_t i = 0; i < digest1.size(); i++) { |
| 55 if (digest1[i] != digest2[i]) | 55 if (digest1[i] != digest2[i]) |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 | 58 |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 static String digestToString(const DigestValue& digest) | 62 static String digestToString(const DigestValue& digest) |
| 63 { | 63 { |
| 64 // We always output base64url encoded data, even though we use base64 intern
ally. | 64 return base64Encode(reinterpret_cast<const char*>(digest.data()), digest.siz
e(), Base64DoNotInsertLFs); |
| 65 return base64URLEncode(reinterpret_cast<const char*>(digest.data()), digest.
size(), Base64DoNotInsertLFs); | |
| 66 } | 65 } |
| 67 | 66 |
| 68 | 67 |
| 69 HashAlgorithm SubresourceIntegrity::getPrioritizedHashFunction(HashAlgorithm alg
orithm1, HashAlgorithm algorithm2) | 68 HashAlgorithm SubresourceIntegrity::getPrioritizedHashFunction(HashAlgorithm alg
orithm1, HashAlgorithm algorithm2) |
| 70 { | 69 { |
| 71 const HashAlgorithm weakerThanSha384[] = { HashAlgorithmSha256 }; | 70 const HashAlgorithm weakerThanSha384[] = { HashAlgorithmSha256 }; |
| 72 const HashAlgorithm weakerThanSha512[] = { HashAlgorithmSha256, HashAlgorith
mSha384 }; | 71 const HashAlgorithm weakerThanSha512[] = { HashAlgorithmSha256, HashAlgorith
mSha384 }; |
| 73 | 72 |
| 74 ASSERT(algorithm1 != HashAlgorithmSha1); | 73 ASSERT(algorithm1 != HashAlgorithmSha1); |
| 75 ASSERT(algorithm2 != HashAlgorithmSha1); | 74 ASSERT(algorithm2 != HashAlgorithmSha1); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 metadataList.append(integrityMetadata); | 317 metadataList.append(integrityMetadata); |
| 319 } | 318 } |
| 320 | 319 |
| 321 if (metadataList.size() == 0 && error) | 320 if (metadataList.size() == 0 && error) |
| 322 return IntegrityParseNoValidResult; | 321 return IntegrityParseNoValidResult; |
| 323 | 322 |
| 324 return IntegrityParseValidResult; | 323 return IntegrityParseValidResult; |
| 325 } | 324 } |
| 326 | 325 |
| 327 } // namespace blink | 326 } // namespace blink |
| OLD | NEW |