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

Unified Diff: content/child/webcrypto/shared_crypto_unittest.cc

Issue 213423007: [webcrypto] Fix a bug where generated RSA private keys couldn't be exported. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment to match wtc's suggestion Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/child/webcrypto/platform_crypto_nss.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/shared_crypto_unittest.cc
diff --git a/content/child/webcrypto/shared_crypto_unittest.cc b/content/child/webcrypto/shared_crypto_unittest.cc
index 696868e28394dc4f1a2c9a9d707b4ef14f535d8f..258d10856c837342e3480ed70d131424abc643f2 100644
--- a/content/child/webcrypto/shared_crypto_unittest.cc
+++ b/content/child/webcrypto/shared_crypto_unittest.cc
@@ -1895,7 +1895,7 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) {
CreateRsaKeyGenAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5,
modulus_length,
public_exponent);
- bool extractable = false;
+ bool extractable = true;
const blink::WebCryptoKeyUsageMask usage_mask = 0;
blink::WebCryptoKey public_key = blink::WebCryptoKey::createNull();
blink::WebCryptoKey private_key = blink::WebCryptoKey::createNull();
@@ -1910,6 +1910,36 @@ TEST_F(SharedCryptoTest, MAYBE(GenerateKeyPairRsa)) {
EXPECT_EQ(usage_mask, public_key.usages());
EXPECT_EQ(usage_mask, private_key.usages());
+ // Try exporting the generated key pair, and then re-importing to verify that
+ // the exported data was valid.
+ blink::WebArrayBuffer public_key_spki;
+ EXPECT_STATUS_SUCCESS(
+ ExportKey(blink::WebCryptoKeyFormatSpki, public_key, &public_key_spki));
+ public_key = blink::WebCryptoKey::createNull();
+ EXPECT_STATUS_SUCCESS(
+ ImportKey(blink::WebCryptoKeyFormatSpki,
+ CryptoData(public_key_spki),
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5),
+ true,
+ usage_mask,
+ &public_key));
+ EXPECT_EQ(modulus_length,
+ public_key.algorithm().rsaParams()->modulusLengthBits());
+
+ blink::WebArrayBuffer private_key_pkcs8;
+ EXPECT_STATUS_SUCCESS(ExportKey(
+ blink::WebCryptoKeyFormatPkcs8, private_key, &private_key_pkcs8));
+ private_key = blink::WebCryptoKey::createNull();
+ EXPECT_STATUS_SUCCESS(
+ ImportKey(blink::WebCryptoKeyFormatPkcs8,
+ CryptoData(private_key_pkcs8),
+ CreateAlgorithm(blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5),
+ true,
+ usage_mask,
+ &private_key));
+ EXPECT_EQ(modulus_length,
+ private_key.algorithm().rsaParams()->modulusLengthBits());
+
// Fail with bad modulus.
algorithm = CreateRsaKeyGenAlgorithm(
blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5, 0, public_exponent);
« no previous file with comments | « content/child/webcrypto/platform_crypto_nss.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698