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 "core/frame/SubresourceIntegrity.h" | 5 #include "core/frame/SubresourceIntegrity.h" |
6 | 6 |
7 #include "core/HTMLNames.h" | 7 #include "core/HTMLNames.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/fetch/IntegrityMetadata.h" | 9 #include "core/fetch/IntegrityMetadata.h" |
10 #include "core/fetch/Resource.h" | 10 #include "core/fetch/Resource.h" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 HashAlgorithmSha512); | 301 HashAlgorithmSha512); |
302 | 302 |
303 expectParse( | 303 expectParse( |
304 "sha-512-tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ-07yMK81ytlg0
MPaIrPAjcHqba5csorDWtKg==?baz=foz?ct=application/xhtml+xml?foo=bar", | 304 "sha-512-tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ-07yMK81ytlg0
MPaIrPAjcHqba5csorDWtKg==?baz=foz?ct=application/xhtml+xml?foo=bar", |
305 "tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAj
cHqba5csorDWtKg==", | 305 "tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAj
cHqba5csorDWtKg==", |
306 HashAlgorithmSha512); | 306 HashAlgorithmSha512); |
307 | 307 |
308 expectParseMultipleHashes("", 0, 0); | 308 expectParseMultipleHashes("", 0, 0); |
309 expectParseMultipleHashes(" ", 0, 0); | 309 expectParseMultipleHashes(" ", 0, 0); |
310 | 310 |
311 const IntegrityMetadata kValidSha384AndSha512[] = { | 311 const IntegrityMetadata validSha384AndSha512[] = { |
312 {"XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr", Has
hAlgorithmSha384}, | 312 IntegrityMetadata("XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEI
up/tA1v5GPr", HashAlgorithmSha384), |
313 {"tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPA
jcHqba5csorDWtKg==", HashAlgorithmSha512} | 313 IntegrityMetadata("tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07
yMK81ytlg0MPaIrPAjcHqba5csorDWtKg==", HashAlgorithmSha512), |
314 }; | 314 }; |
315 expectParseMultipleHashes( | 315 expectParseMultipleHashes( |
316 "sha384-XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr
sha512-tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAjc
Hqba5csorDWtKg==", | 316 "sha384-XVVXBGoYw6AJOh9J+Z8pBDMVVPfkBpngexkA7JqZu8d5GENND6TEIup/tA1v5GPr
sha512-tbUPioKbVBplr0b1ucnWB57SJWt4x9dOE0Vy2mzCXvH3FepqDZ+07yMK81ytlg0MPaIrPAjc
Hqba5csorDWtKg==", |
317 kValidSha384AndSha512, | 317 validSha384AndSha512, |
318 WTF_ARRAY_LENGTH(kValidSha384AndSha512)); | 318 WTF_ARRAY_LENGTH(validSha384AndSha512)); |
319 | 319 |
320 const IntegrityMetadata kValidSha256AndSha256[] = { | 320 const IntegrityMetadata validSha256AndSha256[] = { |
321 {"BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256}, | 321 IntegrityMetadata("BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAl
gorithmSha256), |
322 {"deadbeef", HashAlgorithmSha256} | 322 IntegrityMetadata("deadbeef", HashAlgorithmSha256), |
323 }; | 323 }; |
324 expectParseMultipleHashes( | 324 expectParseMultipleHashes( |
325 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= sha256-deadbeef", | 325 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= sha256-deadbeef", |
326 kValidSha256AndSha256, | 326 validSha256AndSha256, |
327 WTF_ARRAY_LENGTH(kValidSha256AndSha256)); | 327 WTF_ARRAY_LENGTH(validSha256AndSha256)); |
328 | 328 |
329 const IntegrityMetadata kValidSha256AndInvalidSha256[] = { | 329 const IntegrityMetadata validSha256AndInvalidSha256[] = { |
330 {"BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256} | 330 IntegrityMetadata("BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAl
gorithmSha256), |
331 }; | 331 }; |
332 expectParseMultipleHashes( | 332 expectParseMultipleHashes( |
333 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= sha256-!!!!", | 333 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE= sha256-!!!!", |
334 kValidSha256AndInvalidSha256, | 334 validSha256AndInvalidSha256, |
335 WTF_ARRAY_LENGTH(kValidSha256AndInvalidSha256)); | 335 WTF_ARRAY_LENGTH(validSha256AndInvalidSha256)); |
336 | 336 |
337 const IntegrityMetadata kInvalidSha256AndValidSha256[] = { | 337 const IntegrityMetadata invalidSha256AndValidSha256[] = { |
338 {"BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAlgorithmSha256} | 338 IntegrityMetadata("BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", HashAl
gorithmSha256), |
339 }; | 339 }; |
340 expectParseMultipleHashes( | 340 expectParseMultipleHashes( |
341 "sha256-!!! sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", | 341 "sha256-!!! sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", |
342 kInvalidSha256AndValidSha256, | 342 invalidSha256AndValidSha256, |
343 WTF_ARRAY_LENGTH(kInvalidSha256AndValidSha256)); | 343 WTF_ARRAY_LENGTH(invalidSha256AndValidSha256)); |
344 | 344 |
345 expectParse( | 345 expectParse( |
346 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar", | 346 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar", |
347 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", | 347 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", |
348 HashAlgorithmSha256); | 348 HashAlgorithmSha256); |
349 | 349 |
350 expectParse( | 350 expectParse( |
351 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz", | 351 "sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=?foo=bar?baz=foz", |
352 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", | 352 "BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=", |
353 HashAlgorithmSha256); | 353 HashAlgorithmSha256); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 expectIntegrity(kUnsupportedHashFunctionIntegrity, kBasicScript, strlen(kBas
icScript), secureURL, insecureURL); | 434 expectIntegrity(kUnsupportedHashFunctionIntegrity, kBasicScript, strlen(kBas
icScript), secureURL, insecureURL); |
435 | 435 |
436 expectIntegrity(kSha256AndSha384Integrities, kBasicScript, strlen(kBasicScri
pt), secureURL, insecureURL); | 436 expectIntegrity(kSha256AndSha384Integrities, kBasicScript, strlen(kBasicScri
pt), secureURL, insecureURL); |
437 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, strlen(kBa
sicScript), secureURL, insecureURL); | 437 expectIntegrity(kBadSha256AndGoodSha384Integrities, kBasicScript, strlen(kBa
sicScript), secureURL, insecureURL); |
438 | 438 |
439 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript),
secureURL, insecureURL, NoCors); | 439 expectIntegrityFailure(kSha256Integrity, kBasicScript, strlen(kBasicScript),
secureURL, insecureURL, NoCors); |
440 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, str
len(kBasicScript), secureURL, insecureURL); | 440 expectIntegrityFailure(kGoodSha256AndBadSha384Integrities, kBasicScript, str
len(kBasicScript), secureURL, insecureURL); |
441 } | 441 } |
442 | 442 |
443 } // namespace blink | 443 } // namespace blink |
OLD | NEW |