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 "components/webcrypto/algorithm_dispatch.h" | 6 #include "components/webcrypto/algorithm_dispatch.h" |
7 #include "components/webcrypto/algorithms/test_helpers.h" | 7 #include "components/webcrypto/algorithms/test_helpers.h" |
8 #include "components/webcrypto/crypto_data.h" | 8 #include "components/webcrypto/crypto_data.h" |
9 #include "components/webcrypto/status.h" | 9 #include "components/webcrypto/status.h" |
10 #include "components/webcrypto/webcrypto_util.h" | 10 #include "components/webcrypto/webcrypto_util.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 "A256CBC"); | 387 "A256CBC"); |
388 | 388 |
389 // Large usage value | 389 // Large usage value |
390 ImportExportJwkSymmetricKey( | 390 ImportExportJwkSymmetricKey( |
391 256, algorithm, | 391 256, algorithm, |
392 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt | | 392 blink::WebCryptoKeyUsageEncrypt | blink::WebCryptoKeyUsageDecrypt | |
393 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey, | 393 blink::WebCryptoKeyUsageWrapKey | blink::WebCryptoKeyUsageUnwrapKey, |
394 "A256CBC"); | 394 "A256CBC"); |
395 } | 395 } |
396 | 396 |
397 // AES 192-bit is not allowed: http://crbug.com/381829 | 397 // 192-bit AES is intentionally unsupported (http://crubg.com/533699) |
davidben
2015/09/22 19:08:24
ditto
| |
398 TEST_F(WebCryptoAesCbcTest, GenerateAesCbc192) { | 398 TEST_F(WebCryptoAesCbcTest, GenerateAesCbc192) { |
399 blink::WebCryptoKey key; | 399 blink::WebCryptoKey key; |
400 Status status = GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(192), true, | 400 Status status = GenerateSecretKey(CreateAesCbcKeyGenAlgorithm(192), true, |
401 blink::WebCryptoKeyUsageEncrypt, &key); | 401 blink::WebCryptoKeyUsageEncrypt, &key); |
402 ASSERT_EQ(Status::ErrorAes192BitUnsupported(), status); | 402 ASSERT_EQ(Status::ErrorAes192BitUnsupported(), status); |
403 } | 403 } |
404 | 404 |
405 // AES 192-bit is not allowed: http://crbug.com/381829 | 405 // 192-bit AES is intentionally unsupported (http://crubg.com/533699) |
davidben
2015/09/22 19:08:24
ditto
| |
406 TEST_F(WebCryptoAesCbcTest, UnwrapAesCbc192) { | 406 TEST_F(WebCryptoAesCbcTest, UnwrapAesCbc192) { |
407 std::vector<uint8_t> wrapping_key_data(16, 0); | 407 std::vector<uint8_t> wrapping_key_data(16, 0); |
408 std::vector<uint8_t> wrapped_key = HexStringToBytes( | 408 std::vector<uint8_t> wrapped_key = HexStringToBytes( |
409 "1A07ACAB6C906E50883173C29441DB1DE91D34F45C435B5F99C822867FB3956F"); | 409 "1A07ACAB6C906E50883173C29441DB1DE91D34F45C435B5F99C822867FB3956F"); |
410 | 410 |
411 blink::WebCryptoKey wrapping_key = ImportSecretKeyFromRaw( | 411 blink::WebCryptoKey wrapping_key = ImportSecretKeyFromRaw( |
412 wrapping_key_data, CreateAlgorithm(blink::WebCryptoAlgorithmIdAesKw), | 412 wrapping_key_data, CreateAlgorithm(blink::WebCryptoAlgorithmIdAesKw), |
413 blink::WebCryptoKeyUsageUnwrapKey); | 413 blink::WebCryptoKeyUsageUnwrapKey); |
414 | 414 |
415 blink::WebCryptoKey unwrapped_key; | 415 blink::WebCryptoKey unwrapped_key; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
559 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); | 559 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); |
560 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); | 560 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); |
561 | 561 |
562 EXPECT_NE(public_key_spki, wrapped_public_key); | 562 EXPECT_NE(public_key_spki, wrapped_public_key); |
563 EXPECT_NE(private_key_pkcs8, wrapped_private_key); | 563 EXPECT_NE(private_key_pkcs8, wrapped_private_key); |
564 } | 564 } |
565 | 565 |
566 } // namespace | 566 } // namespace |
567 | 567 |
568 } // namespace webcrypto | 568 } // namespace webcrypto |
OLD | NEW |