| 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 "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 Loading... |
| 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 |
| OLD | NEW |