| 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 22 matching lines...) Expand all Loading... |
| 33 &key)); | 33 &key)); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 TEST(WebCryptoAesKwTest, GenerateKeyEmptyUsage) { | 37 TEST(WebCryptoAesKwTest, GenerateKeyEmptyUsage) { |
| 38 blink::WebCryptoKey key; | 38 blink::WebCryptoKey key; |
| 39 EXPECT_EQ(Status::ErrorCreateKeyEmptyUsages(), | 39 EXPECT_EQ(Status::ErrorCreateKeyEmptyUsages(), |
| 40 GenerateSecretKey(CreateAesKwKeyGenAlgorithm(256), true, 0, &key)); | 40 GenerateSecretKey(CreateAesKwKeyGenAlgorithm(256), true, 0, &key)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 TEST(WebCryptoAesKwTest, ImportKeyEmptyUsage) { |
| 44 blink::WebCryptoKey key; |
| 45 EXPECT_EQ(Status::ErrorImportKeyEmptyUsages(), |
| 46 ImportKey(blink::WebCryptoKeyFormatRaw, |
| 47 CryptoData(std::vector<uint8_t>(16)), |
| 48 CreateAlgorithm(blink::WebCryptoAlgorithmIdAesKw), |
| 49 true, 0, &key)); |
| 50 } |
| 51 |
| 43 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { | 52 TEST(WebCryptoAesKwTest, ImportKeyJwkKeyOpsWrapUnwrap) { |
| 44 blink::WebCryptoKey key; | 53 blink::WebCryptoKey key; |
| 45 base::DictionaryValue dict; | 54 base::DictionaryValue dict; |
| 46 dict.SetString("kty", "oct"); | 55 dict.SetString("kty", "oct"); |
| 47 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg"); | 56 dict.SetString("k", "GADWrMRHwQfoNaXU5fZvTg"); |
| 48 base::ListValue* key_ops = new base::ListValue; | 57 base::ListValue* key_ops = new base::ListValue; |
| 49 dict.Set("key_ops", key_ops); // Takes ownership. | 58 dict.Set("key_ops", key_ops); // Takes ownership. |
| 50 | 59 |
| 51 key_ops->AppendString("wrapKey"); | 60 key_ops->AppendString("wrapKey"); |
| 52 | 61 |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 blink::WebCryptoAlgorithmIdSha256), | 527 blink::WebCryptoAlgorithmIdSha256), |
| 519 true, bad_usages[i], &key)); | 528 true, bad_usages[i], &key)); |
| 520 } | 529 } |
| 521 } | 530 } |
| 522 | 531 |
| 523 } // namespace | 532 } // namespace |
| 524 | 533 |
| 525 } // namespace webcrypto | 534 } // namespace webcrypto |
| 526 | 535 |
| 527 } // namespace content | 536 } // namespace content |
| OLD | NEW |