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

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: 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
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 "content/child/webcrypto/shared_crypto.h" 5 #include "content/child/webcrypto/shared_crypto.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type()); 1995 EXPECT_EQ(blink::WebCryptoKeyTypeSecret, key.type());
1996 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits()); 1996 EXPECT_EQ(0u, key.algorithm().hmacParams()->lengthBits());
1997 1997
1998 std::vector<uint8> exported_key_data; 1998 std::vector<uint8> exported_key_data;
1999 EXPECT_EQ(Status::Success(), 1999 EXPECT_EQ(Status::Success(),
2000 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data)); 2000 ExportKey(blink::WebCryptoKeyFormatRaw, key, &exported_key_data));
2001 2001
2002 EXPECT_EQ(0u, exported_key_data.size()); 2002 EXPECT_EQ(0u, exported_key_data.size());
2003 } 2003 }
2004 2004
2005 TEST_F(SharedCryptoTest, MAYBE(ImportExportSpki)) { 2005 TEST_F(SharedCryptoTest, ImportExportSpki) {
2006 if (!SupportsRsaKeyImport()) 2006 if (!SupportsRsaKeyImport())
2007 return; 2007 return;
2008 2008
2009 // Passing case: Import a valid RSA key in SPKI format. 2009 // Passing case: Import a valid RSA key in SPKI format.
2010 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 2010 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
2011 ASSERT_EQ(Status::Success(), 2011 ASSERT_EQ(Status::Success(),
2012 ImportKey(blink::WebCryptoKeyFormatSpki, 2012 ImportKey(blink::WebCryptoKeyFormatSpki,
2013 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)), 2013 CryptoData(HexStringToBytes(kPublicKeySpkiDerHex)),
2014 CreateRsaHashedImportAlgorithm( 2014 CreateRsaHashedImportAlgorithm(
2015 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, 2015 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output)); 2084 ExportKey(blink::WebCryptoKeyFormatSpki, key, &output));
2085 2085
2086 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID 2086 // TODO(eroman): Failing test: Import a SPKI with an unrecognized hash OID
2087 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params 2087 // TODO(eroman): Failing test: Import a SPKI with invalid algorithm params
2088 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters 2088 // TODO(eroman): Failing test: Import a SPKI with inconsistent parameters
2089 // (e.g. SHA-1 in OID, SHA-256 in params) 2089 // (e.g. SHA-1 in OID, SHA-256 in params)
2090 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params 2090 // TODO(eroman): Failing test: Import a SPKI for RSA-SSA, but with params
2091 // as OAEP/PSS 2091 // as OAEP/PSS
2092 } 2092 }
2093 2093
2094 TEST_F(SharedCryptoTest, MAYBE(ImportExportPkcs8)) { 2094 TEST_F(SharedCryptoTest, ImportExportPkcs8) {
2095 if (!SupportsRsaKeyImport()) 2095 if (!SupportsRsaKeyImport())
2096 return; 2096 return;
2097 2097
2098 // Passing case: Import a valid RSA key in PKCS#8 format. 2098 // Passing case: Import a valid RSA key in PKCS#8 format.
2099 blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); 2099 blink::WebCryptoKey key = blink::WebCryptoKey::createNull();
2100 ASSERT_EQ(Status::Success(), 2100 ASSERT_EQ(Status::Success(),
2101 ImportKey(blink::WebCryptoKeyFormatPkcs8, 2101 ImportKey(blink::WebCryptoKeyFormatPkcs8,
2102 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)), 2102 CryptoData(HexStringToBytes(kPrivateKeyPkcs8DerHex)),
2103 CreateRsaHashedImportAlgorithm( 2103 CreateRsaHashedImportAlgorithm(
2104 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5, 2104 blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5,
(...skipping 2266 matching lines...) Expand 10 before | Expand all | Expand 10 after
4371 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki); 4371 EXPECT_EQ(public_key_spki, unwrapped_public_key_spki);
4372 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8); 4372 EXPECT_EQ(private_key_pkcs8, unwrapped_private_key_pkcs8);
4373 4373
4374 EXPECT_NE(public_key_spki, wrapped_public_key); 4374 EXPECT_NE(public_key_spki, wrapped_public_key);
4375 EXPECT_NE(private_key_pkcs8, wrapped_private_key); 4375 EXPECT_NE(private_key_pkcs8, wrapped_private_key);
4376 } 4376 }
4377 4377
4378 } // namespace webcrypto 4378 } // namespace webcrypto
4379 4379
4380 } // namespace content 4380 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698