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/stl_util.h" | 5 #include "base/stl_util.h" |
6 #include "content/child/webcrypto/algorithm_dispatch.h" | 6 #include "content/child/webcrypto/algorithm_dispatch.h" |
7 #include "content/child/webcrypto/crypto_data.h" | 7 #include "content/child/webcrypto/crypto_data.h" |
8 #include "content/child/webcrypto/status.h" | 8 #include "content/child/webcrypto/status.h" |
9 #include "content/child/webcrypto/test/test_helpers.h" | 9 #include "content/child/webcrypto/test/test_helpers.h" |
10 #include "content/child/webcrypto/webcrypto_util.h" | 10 #include "content/child/webcrypto/webcrypto_util.h" |
11 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 11 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
12 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 12 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
13 | 13 |
14 namespace content { | 14 namespace content { |
15 | 15 |
16 namespace webcrypto { | 16 namespace webcrypto { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 blink::WebCryptoAlgorithm CreateAesKwKeyGenAlgorithm( | 20 blink::WebCryptoAlgorithm CreateAesKwKeyGenAlgorithm( |
21 unsigned short key_length_bits) { | 21 unsigned short key_length_bits) { |
22 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesKw, | 22 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesKw, |
23 key_length_bits); | 23 key_length_bits); |
24 } | 24 } |
25 | 25 |
26 TEST(WebCryptoAesKwTest, GenerateKeyBadLength) { | 26 TEST(WebCryptoAesKwTest, GenerateKeyBadLength) { |
27 const unsigned short kKeyLen[] = {0, 127, 257}; | 27 const unsigned short kKeyLen[] = {0, 127, 257}; |
28 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 28 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
29 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kKeyLen); ++i) { | 29 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { |
30 SCOPED_TRACE(i); | 30 SCOPED_TRACE(i); |
31 EXPECT_EQ(Status::ErrorGenerateKeyLength(), | 31 EXPECT_EQ(Status::ErrorGenerateKeyLength(), |
32 GenerateSecretKey( | 32 GenerateSecretKey( |
33 CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); | 33 CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, &key)); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
37 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { | 37 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { |
38 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 38 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
39 base::DictionaryValue dict; | 39 base::DictionaryValue dict; |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 bad_usages[i], | 598 bad_usages[i], |
599 &key)); | 599 &key)); |
600 } | 600 } |
601 } | 601 } |
602 | 602 |
603 } // namespace | 603 } // namespace |
604 | 604 |
605 } // namespace webcrypto | 605 } // namespace webcrypto |
606 | 606 |
607 } // namespace content | 607 } // namespace content |
OLD | NEW |