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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2006 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); | 2006 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); |
2007 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits()); | 2007 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits()); |
2008 | 2008 |
2009 std::vector<uint8> exported_key_data; | 2009 std::vector<uint8> exported_key_data; |
2010 EXPECT_EQ(Status::Success(), | 2010 EXPECT_EQ(Status::Success(), |
2011 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); | 2011 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); |
2012 | 2012 |
2013 EXPECT_EQ(0u, exported_key_data.size()); | 2013 EXPECT_EQ(0u, exported_key_data.size()); |
2014 } | 2014 } |
2015 | 2015 |
2016 TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) { | 2016 TEST_F(SharedCryptoTest, ImportExportSpki) { |
2017 if (!SupportsRsaKeyImport()) | 2017 if (!SupportsRsaKeyImport()) |
2018 return; | 2018 return; |
2019 | 2019 |
2020 // Passing case: Import a valid RSA key in SPKI format. | 2020 // Passing case: Import a valid RSA key in SPKI format. |
2021 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 2021 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
2022 ASSERT_EQ(Status::Success(), | 2022 ASSERT_EQ(Status::Success(), |
2023 ImportKey(blink::WebCryptoKeyFormatSpki, | 2023 ImportKey(blink::WebCryptoKeyFormatSpki, |
2024 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)), | 2024 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)), |
2025 CreateRsaHashedImportAlgorithm( | 2025 CreateRsaHashedImportAlgorithm( |
2026 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 2026 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2095 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); | 2095 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); |
2096 | 2096 |
2097 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID | 2097 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID |
2098 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params | 2098 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params |
2099 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters | 2099 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters |
2100 // (e.g. SHA-1 in OID, SHA-256 in params) | 2100 // (e.g. SHA-1 in OID, SHA-256 in params) |
2101 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params | 2101 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params |
2102 // as OAEP/PSS | 2102 // as OAEP/PSS |
2103 } | 2103 } |
2104 | 2104 |
2105 TEST_F(SharedCryptoTest, MAYBE(ImportExportPkcs8)) { | 2105 TEST_F(SharedCryptoTest, ImportExportPkcs8) { |
2106 if (!SupportsRsaKeyImport()) | 2106 if (!SupportsRsaKeyImport()) |
2107 return; | 2107 return; |
2108 | 2108 |
2109 // Passing case: Import a valid RSA key in PKCS#8 format. | 2109 // Passing case: Import a valid RSA key in PKCS#8 format. |
2110 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); | 2110 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); |
2111 ASSERT_EQ(Status::Success(), | 2111 ASSERT_EQ(Status::Success(), |
2112 ImportKey(blink::WebCryptoKeyFormatPkcs8, | 2112 ImportKey(blink::WebCryptoKeyFormatPkcs8, |
2113 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)), | 2113 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)), |
2114 CreateRsaHashedImportAlgorithm( | 2114 CreateRsaHashedImportAlgorithm( |
2115 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, | 2115 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, |
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4418 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); | 4418 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); |
4419 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); | 4419 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); |
4420 | 4420 |
4421 EXPECT_NE(public_key_spki, wrapped_public_key); | 4421 EXPECT_NE(public_key_spki, wrapped_public_key); |
4422 EXPECT_NE(private_key_pkcs8, wrapped_private_key); | 4422 EXPECT_NE(private_key_pkcs8, wrapped_private_key); |
4423 } | 4423 } |
4424 | 4424 |
4425 } // namespace webcrypto | 4425 } // namespace webcrypto |
4426 | 4426 |
4427 } // namespace content | 4427 } // namespace content |
OLD | NEW |