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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 const unsigned short kKeyLen[] = {0, 127, 257}; | 27 const unsigned short kKeyLen[] = {0, 127, 257}; |
28 blink::WebCryptoKey key; | 28 blink::WebCryptoKey key; |
29 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { | 29 for (size_t i = 0; i < arraysize(kKeyLen); ++i) { |
30 SCOPED_TRACE(i); | 30 SCOPED_TRACE(i); |
31 EXPECT_EQ(Status::ErrorGenerateAesKeyLength(), | 31 EXPECT_EQ(Status::ErrorGenerateAesKeyLength(), |
32 GenerateSecretKey(CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, | 32 GenerateSecretKey(CreateAesKwKeyGenAlgorithm(kKeyLen[i]), true, 0, |
33 &key)); | 33 &key)); |
34 } | 34 } |
35 } | 35 } |
36 | 36 |
| 37 TEST(WebCryptoAesKwTest, GenerateKeyEmptyUsage) { |
| 38 blink::WebCryptoKey key; |
| 39 EXPECT_EQ(Status::ErrorCreateKeyEmptyUsages(), |
| 40 GenerateSecretKey(CreateAesKwKeyGenAlgorithm(256), true, 0, &key)); |
| 41 } |
| 42 |
37 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { | 43 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { |
38 blink::WebCryptoKey key; | 44 blink::WebCryptoKey key; |
39 base::DictionaryValue dict; | 45 base::DictionaryValue dict; |
40 dict.SetString("kty", "oct"); | 46 dict.SetString("kty", "oct"); |
41 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg"); | 47 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg"); |
42 base::ListValue* key_ops = new base::ListValue; | 48 base::ListValue* key_ops = new base::ListValue; |
43 dict.Set("key_ops", key_ops); // Takes ownership. | 49 dict.Set("key_ops", key_ops); // Takes ownership. |
44 | 50 |
45 key_ops->AppendString("wrapKey"); | 51 key_ops->AppendString("wrapKey"); |
46 | 52 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 blink::WebCryptoAlgorithmIdSha256), | 518 blink::WebCryptoAlgorithmIdSha256), |
513 true, bad_usages[i], &key)); | 519 true, bad_usages[i], &key)); |
514 } | 520 } |
515 } | 521 } |
516 | 522 |
517 } // namespace | 523 } // namespace |
518 | 524 |
519 } // namespace webcrypto | 525 } // namespace webcrypto |
520 | 526 |
521 } // namespace content | 527 } // namespace content |
OLD | NEW |