Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 353043005: [webcrypto] Wire up {spki, pkcs8} import/export for OpenSSL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase onto master (which no longer has boringssl) Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/webcrypto/openssl/util_openssl.cc ('k') | content/content_child.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after
2007 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); 2007 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
2008 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits()); 2008 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits());
2009 2009
2010 std::vector<uint8_t> exported_key_data; 2010 std::vector<uint8_t> exported_key_data;
2011 EXPECT_EQ(Status::Success(), 2011 EXPECT_EQ(Status::Success(),
2012 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); 2012 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data));
2013 2013
2014 EXPECT_EQ(0u, exported_key_data.size()); 2014 EXPECT_EQ(0u, exported_key_data.size());
2015 } 2015 }
2016 2016
2017 TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) { 2017 TEST_F(SharedCryptoTest, ImportExportSpki) {
2018 if (!SupportsRsaKeyImport()) 2018 if (!SupportsRsaKeyImport())
2019 return; 2019 return;
2020 2020
2021 // Passing case: Import a valid RSA key in SPKI format. 2021 // Passing case: Import a valid RSA key in SPKI format.
2022 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 2022 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
2023 ASSERT_EQ(Status::Success(), 2023 ASSERT_EQ(Status::Success(),
2024 ImportKey(blink::WebCryptoKeyFormatSpki, 2024 ImportKey(blink::WebCryptoKeyFormatSpki,
2025 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)), 2025 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)),
2026 CreateRsaHashedImportAlgorithm( 2026 CreateRsaHashedImportAlgorithm(
2027 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, 2027 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); 2096 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output));
2097 2097
2098 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID 2098 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID
2099 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params 2099 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params
2100 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters 2100 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters
2101 // (e.g. SHA-1 in OID, SHA-256 in params) 2101 // (e.g. SHA-1 in OID, SHA-256 in params)
2102 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params 2102 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params
2103 // as OAEP/PSS 2103 // as OAEP/PSS
2104 } 2104 }
2105 2105
2106 TEST_F(SharedCryptoTest, MAYBE(ImportExportPkcs8)) { 2106 TEST_F(SharedCryptoTest, ImportExportPkcs8) {
2107 if (!SupportsRsaKeyImport()) 2107 if (!SupportsRsaKeyImport())
2108 return; 2108 return;
2109 2109
2110 // Passing case: Import a valid RSA key in PKCS#8 format. 2110 // Passing case: Import a valid RSA key in PKCS#8 format.
2111 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 2111 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
2112 ASSERT_EQ(Status::Success(), 2112 ASSERT_EQ(Status::Success(),
2113 ImportKey(blink::WebCryptoKeyFormatPkcs8, 2113 ImportKey(blink::WebCryptoKeyFormatPkcs8,
2114 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)), 2114 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
2115 CreateRsaHashedImportAlgorithm( 2115 CreateRsaHashedImportAlgorithm(
2116 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, 2116 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
(...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); 4419 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki);
4420 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); 4420 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8);
4421 4421
4422 EXPECT_NE(public_key_spki, wrapped_public_key); 4422 EXPECT_NE(public_key_spki, wrapped_public_key);
4423 EXPECT_NE(private_key_pkcs8, wrapped_private_key); 4423 EXPECT_NE(private_key_pkcs8, wrapped_private_key);
4424 } 4424 }
4425 4425
4426 } // namespace webcrypto 4426 } // namespace webcrypto
4427 4427
4428 } // namespace content 4428 } // namespace content
OLDNEW
« no previous file with comments | « content/child/webcrypto/openssl/util_openssl.cc ('k') | content/content_child.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698