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

Side by Side Diff: content/child/webcrypto/test/hmac_unittest.cc

Issue 508793002: Check for integer overflow when HMAC key length as bits cannot fit in an unsigned int. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « content/child/webcrypto/openssl/hmac_openssl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "content/child/webcrypto/algorithm_dispatch.h" 7 #include "content/child/webcrypto/algorithm_dispatch.h"
8 #include "content/child/webcrypto/crypto_data.h" 8 #include "content/child/webcrypto/crypto_data.h"
9 #include "content/child/webcrypto/status.h" 9 #include "content/child/webcrypto/status.h"
10 #include "content/child/webcrypto/test/test_helpers.h" 10 #include "content/child/webcrypto/test/test_helpers.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); 516 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
517 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits()); 517 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits());
518 518
519 std::vector<uint8_t> exported_key_data; 519 std::vector<uint8_t> exported_key_data;
520 EXPECT_EQ(Status::Success(), 520 EXPECT_EQ(Status::Success(),
521 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); 521 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data));
522 522
523 EXPECT_EQ(0u, exported_key_data.size()); 523 EXPECT_EQ(0u, exported_key_data.size());
524 } 524 }
525 525
526 // Import a huge hmac key (UINT_MAX bytes). This will fail before actually
527 // reading the bytes, as the key is too large.
528 TEST(WebCryptoHmacTest, ImportRawKeyTooLarge) {
529 CryptoData big_data(NULL, UINT_MAX); // Invalid data of big length.
530
531 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
532 EXPECT_EQ(
533 Status::ErrorDataTooLarge(),
534 ImportKey(blink::WebCryptoKeyFormatRaw,
535 CryptoData(big_data),
536 CreateHmacImportAlgorithm(blink::WebCryptoAlgorithmIdSha1),
537 true,
538 blink::WebCryptoKeyUsageSign,
539 &key));
540 }
541
526 } // namespace 542 } // namespace
527 543
528 } // namespace webcrypto 544 } // namespace webcrypto
529 545
530 } // namespace content 546 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/hmac_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698