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" | |
6 #include "base/values.h" | 5 #include "base/values.h" |
7 #include "components/webcrypto/algorithm_dispatch.h" | 6 #include "components/webcrypto/algorithm_dispatch.h" |
8 #include "components/webcrypto/algorithms/test_helpers.h" | 7 #include "components/webcrypto/algorithms/test_helpers.h" |
9 #include "components/webcrypto/crypto_data.h" | 8 #include "components/webcrypto/crypto_data.h" |
10 #include "components/webcrypto/status.h" | 9 #include "components/webcrypto/status.h" |
11 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 10 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
12 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 11 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
13 | 12 |
14 namespace webcrypto { | 13 namespace webcrypto { |
15 | 14 |
16 namespace { | 15 namespace { |
17 | 16 |
18 // Creates an AES-CBC algorithm. | 17 // Creates an AES-CBC algorithm. |
19 blink::WebCryptoAlgorithm CreateAesCbcAlgorithm( | 18 blink::WebCryptoAlgorithm CreateAesCbcAlgorithm( |
20 const std::vector<uint8_t>& iv) { | 19 const std::vector<uint8_t>& iv) { |
21 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( | 20 return blink::WebCryptoAlgorithm::adoptParamsAndCreate( |
22 blink::WebCryptoAlgorithmIdAesCbc, | 21 blink::WebCryptoAlgorithmIdAesCbc, |
23 new blink::WebCryptoAesCbcParams(vector_as_array(&iv), | 22 new blink::WebCryptoAesCbcParams(iv.data(), |
24 static_cast<unsigned int>(iv.size()))); | 23 static_cast<unsigned int>(iv.size()))); |
25 } | 24 } |
26 | 25 |
27 blink::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm( | 26 blink::WebCryptoAlgorithm CreateAesCbcKeyGenAlgorithm( |
28 unsigned short key_length_bits) { | 27 unsigned short key_length_bits) { |
29 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesCbc, | 28 return CreateAesKeyGenAlgorithm(blink::WebCryptoAlgorithmIdAesCbc, |
30 key_length_bits); | 29 key_length_bits); |
31 } | 30 } |
32 | 31 |
33 blink::WebCryptoKey GetTestAesCbcKey() { | 32 blink::WebCryptoKey GetTestAesCbcKey() { |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); | 558 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); |
560 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); | 559 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); |
561 | 560 |
562 EXPECT_NE(public_key_spki, wrapped_public_key); | 561 EXPECT_NE(public_key_spki, wrapped_public_key); |
563 EXPECT_NE(private_key_pkcs8, wrapped_private_key); | 562 EXPECT_NE(private_key_pkcs8, wrapped_private_key); |
564 } | 563 } |
565 | 564 |
566 } // namespace | 565 } // namespace |
567 | 566 |
568 } // namespace webcrypto | 567 } // namespace webcrypto |
OLD | NEW |