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

Unified Diff: content/child/webcrypto/test/ecdsa_unittest.cc

Issue 835633002: Change the WebCrypto behavior when importing EC private keys without a public key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_private_tests
Patch Set: properly rebase Created 5 years, 11 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
Index: content/child/webcrypto/test/ecdsa_unittest.cc
diff --git a/content/child/webcrypto/test/ecdsa_unittest.cc b/content/child/webcrypto/test/ecdsa_unittest.cc
index f974622d62822af19fc7b552b4b4cad5720dff42..3e948a27fa520a43f17351fc5758b7c623ead0d3 100644
--- a/content/child/webcrypto/test/ecdsa_unittest.cc
+++ b/content/child/webcrypto/test/ecdsa_unittest.cc
@@ -301,7 +301,8 @@ TEST(WebCryptoEcdsaTest, ImportExportPrivateKey) {
const base::DictionaryValue* jwk_dict;
EXPECT_TRUE(test->GetDictionary("jwk", &jwk_dict));
std::vector<uint8_t> jwk_bytes = MakeJsonVector(*jwk_dict);
- std::vector<uint8_t> pkcs8_bytes = GetBytesFromHexString(test, "pkcs8");
+ std::vector<uint8_t> pkcs8_bytes = GetBytesFromHexString(
+ test, test->HasKey("exported_pkcs8") ? "exported_pkcs8" : "pkcs8");
// -------------------------------------------------
// Test from JWK, and then export to {JWK, PKCS8}
@@ -345,9 +346,17 @@ TEST(WebCryptoEcdsaTest, ImportExportPrivateKey) {
// Test from PKCS8, and then export to {JWK, PKCS8}
// -------------------------------------------------
+ // The imported PKCS8 bytes may differ from the exported bytes (in the case
+ // where the publicKey was missing, it will be synthesized and written back
+ // during export).
+ std::vector<uint8_t> pkcs8_input_bytes = GetBytesFromHexString(
+ test, test->HasKey("original_pkcs8") ? "original_pkcs8" : "pkcs8");
+ CryptoData pkcs8_input_data(pkcs8_input_bytes.empty() ? pkcs8_bytes
+ : pkcs8_input_bytes);
+
// Import the key using PKCS8
ASSERT_EQ(Status::Success(),
- ImportKey(blink::WebCryptoKeyFormatPkcs8, CryptoData(pkcs8_bytes),
+ ImportKey(blink::WebCryptoKeyFormatPkcs8, pkcs8_input_data,
CreateEcdsaImportAlgorithm(curve), true,
blink::WebCryptoKeyUsageSign, &key));
« no previous file with comments | « content/child/webcrypto/openssl/ec_algorithm_openssl.cc ('k') | content/test/data/webcrypto/ec_private_keys.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698