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 18 matching lines...) Expand all Loading... | |
29 // key_length_bytes == 0 means unspecified | 29 // key_length_bytes == 0 means unspecified |
30 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 30 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
31 blink::WebCryptoAlgorithmIdHmac, | 31 blink::WebCryptoAlgorithmIdHmac, |
32 new blink::WebCryptoHmacKeyGenParams( | 32 new blink::WebCryptoHmacKeyGenParams( |
33 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits)); | 33 CreateAlgorithm(hash_id), (key_length_bits != 0), key_length_bits)); |
34 } | 34 } |
35 | 35 |
36 TEST(WebCryptoHmacTest, HMACSampleSets) { | 36 TEST(WebCryptoHmacTest, HMACSampleSets) { |
37 scoped_ptr<base::ListValue> tests; | 37 scoped_ptr<base::ListValue> tests; |
38 ASSERT_TRUE(ReadJsonTestFileToList("hmac.json", &tests)); | 38 ASSERT_TRUE(ReadJsonTestFileToList("hmac.json", &tests)); |
39 // TODO(padolph): Missing known answer tests for HMAC SHA384, and SHA512. | |
eroman
2014/08/26 18:13:05
SHA-512 and SHA-384 are part of hmac.json
| |
40 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { | 39 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { |
41 SCOPED_TRACE(test_index); | 40 SCOPED_TRACE(test_index); |
42 base::DictionaryValue* test; | 41 base::DictionaryValue* test; |
43 ASSERT_TRUE(tests->GetDictionary(test_index, &test)); | 42 ASSERT_TRUE(tests->GetDictionary(test_index, &test)); |
44 | 43 |
45 blink::WebCryptoAlgorithm test_hash = GetDigestAlgorithm(test, "hash"); | 44 blink::WebCryptoAlgorithm test_hash = GetDigestAlgorithm(test, "hash"); |
46 const std::vector<uint8_t> test_key = GetBytesFromHexString(test, "key"); | 45 const std::vector<uint8_t> test_key = GetBytesFromHexString(test, "key"); |
47 const std::vector<uint8_t> test_message = | 46 const std::vector<uint8_t> test_message = |
48 GetBytesFromHexString(test, "message"); | 47 GetBytesFromHexString(test, "message"); |
49 const std::vector<uint8_t> test_mac = GetBytesFromHexString(test, "mac"); | 48 const std::vector<uint8_t> test_mac = GetBytesFromHexString(test, "mac"); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); | 520 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); |
522 | 521 |
523 EXPECT_EQ(0u, exported_key_data.size()); | 522 EXPECT_EQ(0u, exported_key_data.size()); |
524 } | 523 } |
525 | 524 |
526 } // namespace | 525 } // namespace |
527 | 526 |
528 } // namespace webcrypto | 527 } // namespace webcrypto |
529 | 528 |
530 } // namespace content | 529 } // namespace content |
OLD | NEW |