summaryrefslogtreecommitdiff
path: root/chromium/components/webcrypto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-12 15:59:20 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-25 06:57:22 +0000
commitf7eaed5286974984ba5f9e3189d8f49d03e99f81 (patch)
treecaed19b2af2024f35449fb0b781d0a25e09d4f8f /chromium/components/webcrypto
parent9729c4479fe23554eae6e6dd1f30ff488f470c84 (diff)
downloadqtwebengine-chromium-f7eaed5286974984ba5f9e3189d8f49d03e99f81.tar.gz
BASELINE: Update Chromium to 100.0.4896.167
Change-Id: I98cbeb5d7543d966ffe04d8cefded0c493a11333 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/webcrypto')
-rw-r--r--chromium/components/webcrypto/algorithms/aes_cbc_unittest.cc12
-rw-r--r--chromium/components/webcrypto/algorithms/aes_ctr_unittest.cc8
-rw-r--r--chromium/components/webcrypto/algorithms/aes_gcm_unittest.cc8
-rw-r--r--chromium/components/webcrypto/algorithms/aes_kw_unittest.cc32
-rw-r--r--chromium/components/webcrypto/algorithms/ecdh_unittest.cc22
-rw-r--r--chromium/components/webcrypto/algorithms/ecdsa_unittest.cc40
-rw-r--r--chromium/components/webcrypto/algorithms/hmac_unittest.cc8
-rw-r--r--chromium/components/webcrypto/algorithms/rsa_oaep_unittest.cc8
-rw-r--r--chromium/components/webcrypto/algorithms/rsa_pss_unittest.cc17
-rw-r--r--chromium/components/webcrypto/algorithms/rsa_ssa_unittest.cc32
-rw-r--r--chromium/components/webcrypto/algorithms/sha_unittest.cc8
-rw-r--r--chromium/components/webcrypto/algorithms/test_helpers.cc41
-rw-r--r--chromium/components/webcrypto/algorithms/test_helpers.h19
-rw-r--r--chromium/components/webcrypto/jwk.cc2
14 files changed, 120 insertions, 137 deletions
diff --git a/chromium/components/webcrypto/algorithms/aes_cbc_unittest.cc b/chromium/components/webcrypto/algorithms/aes_cbc_unittest.cc
index 980f661a061..17763859165 100644
--- a/chromium/components/webcrypto/algorithms/aes_cbc_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/aes_cbc_unittest.cc
@@ -90,13 +90,13 @@ TEST_F(WebCryptoAesCbcTest, ExportKeyUnsupportedFormat) {
// Tests importing of keys (in a variety of formats), errors during import,
// encryption, and decryption, using known answers.
TEST_F(WebCryptoAesCbcTest, KnownAnswerEncryptDecrypt) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_cbc.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_cbc.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -119,7 +119,7 @@ TEST_F(WebCryptoAesCbcTest, KnownAnswerEncryptDecrypt) {
continue;
// Test encryption.
- if (test->HasKey("plain_text")) {
+ if (test->FindKey("plain_text")) {
std::vector<uint8_t> test_plain_text =
GetBytesFromHexString(test, "plain_text");
@@ -142,7 +142,7 @@ TEST_F(WebCryptoAesCbcTest, KnownAnswerEncryptDecrypt) {
}
// Test decryption.
- if (test->HasKey("cipher_text")) {
+ if (test->FindKey("cipher_text")) {
std::vector<uint8_t> test_cipher_text =
GetBytesFromHexString(test, "cipher_text");
diff --git a/chromium/components/webcrypto/algorithms/aes_ctr_unittest.cc b/chromium/components/webcrypto/algorithms/aes_ctr_unittest.cc
index 54e5eecf1dd..62ec5215576 100644
--- a/chromium/components/webcrypto/algorithms/aes_ctr_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/aes_ctr_unittest.cc
@@ -30,13 +30,13 @@ blink::WebCryptoAlgorithm CreateAesCtrAlgorithm(
class WebCryptoAesCtrTest : public WebCryptoTestBase {};
TEST_F(WebCryptoAesCtrTest, EncryptDecryptKnownAnswer) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_ctr.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_ctr.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/aes_gcm_unittest.cc b/chromium/components/webcrypto/algorithms/aes_gcm_unittest.cc
index b98408e6afc..7f645902c84 100644
--- a/chromium/components/webcrypto/algorithms/aes_gcm_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/aes_gcm_unittest.cc
@@ -133,14 +133,14 @@ TEST_F(WebCryptoAesGcmTest, ImportExportJwk) {
// * Test decryption with empty input
// * Test decryption with tag length of 0.
TEST_F(WebCryptoAesGcmTest, SampleSets) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_gcm.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_gcm.json", &tests));
// Note that WebCrypto appends the authentication tag to the ciphertext.
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/aes_kw_unittest.cc b/chromium/components/webcrypto/algorithms/aes_kw_unittest.cc
index 4c547afa96a..a96303d425e 100644
--- a/chromium/components/webcrypto/algorithms/aes_kw_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/aes_kw_unittest.cc
@@ -162,9 +162,9 @@ TEST_F(WebCryptoAesKwTest, AesKwKeyImport) {
TEST_F(WebCryptoAesKwTest, UnwrapFailures) {
// This test exercises the code path common to all unwrap operations.
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_kw.json", &tests));
- const base::Value& test_value = tests.GetList()[0];
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_kw.json", &tests));
+ const base::Value& test_value = tests.GetListDeprecated()[0];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -188,13 +188,13 @@ TEST_F(WebCryptoAesKwTest, UnwrapFailures) {
}
TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyWrapUnwrapKnownAnswer) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_kw.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_kw.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -250,10 +250,10 @@ TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyWrapUnwrapKnownAnswer) {
// Unwrap a HMAC key using AES-KW, and then try doing a sign/verify with the
// unwrapped key
TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyUnwrapSignVerifyHmac) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_kw.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_kw.json", &tests));
- const base::Value& test_value = tests.GetList()[0];
+ const base::Value& test_value = tests.GetListDeprecated()[0];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -303,10 +303,10 @@ TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyUnwrapSignVerifyHmac) {
}
TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyWrapUnwrapErrors) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_kw.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_kw.json", &tests));
// Use 256 bits of data with a 256-bit KEK
- const base::Value& test_value = tests.GetList()[3];
+ const base::Value& test_value = tests.GetListDeprecated()[3];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -346,10 +346,10 @@ TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyWrapUnwrapErrors) {
}
TEST_F(WebCryptoAesKwTest, AesKwRawSymkeyUnwrapCorruptData) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("aes_kw.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("aes_kw.json", &tests));
// Use 256 bits of data with a 256-bit KEK
- const base::Value& test_value = tests.GetList()[3];
+ const base::Value& test_value = tests.GetListDeprecated()[3];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/ecdh_unittest.cc b/chromium/components/webcrypto/algorithms/ecdh_unittest.cc
index cd8ceaae34a..02515ff8994 100644
--- a/chromium/components/webcrypto/algorithms/ecdh_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/ecdh_unittest.cc
@@ -75,14 +75,14 @@ bool ImportKeysFromTest(const base::DictionaryValue* test,
class WebCryptoEcdhTest : public WebCryptoTestBase {};
TEST_F(WebCryptoEcdhTest, DeriveBitsKnownAnswer) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("ecdh.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("ecdh.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -120,16 +120,16 @@ TEST_F(WebCryptoEcdhTest, DeriveBitsKnownAnswer) {
// 528 bits.
::testing::AssertionResult LoadTestKeys(blink::WebCryptoKey* public_key,
blink::WebCryptoKey* private_key) {
- base::ListValue tests;
- if (!ReadJsonTestFileToList("ecdh.json", &tests))
+ base::Value tests;
+ if (!ReadJsonTestFileAsList("ecdh.json", &tests))
return ::testing::AssertionFailure() << "Failed loading ecdh.json";
const base::DictionaryValue* test = nullptr;
bool valid_p521_keys = false;
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
EXPECT_TRUE(test_value.is_dict());
test = &base::Value::AsDictionaryValue(test_value);
absl::optional<bool> keys = test->FindBoolKey("valid_p521_keys");
@@ -308,10 +308,10 @@ TEST_F(WebCryptoEcdhTest, DeriveKeyAes128) {
TEST_F(WebCryptoEcdhTest, ImportKeyEmptyUsage) {
blink::WebCryptoKey key;
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("ecdh.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("ecdh.json", &tests));
- const base::Value& test_value = tests.GetList()[0];
+ const base::Value& test_value = tests.GetListDeprecated()[0];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/ecdsa_unittest.cc b/chromium/components/webcrypto/algorithms/ecdsa_unittest.cc
index b829f09680a..291bc71f820 100644
--- a/chromium/components/webcrypto/algorithms/ecdsa_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/ecdsa_unittest.cc
@@ -96,9 +96,9 @@ TEST_F(WebCryptoEcdsaTest, SignatureIsRandom) {
// Import a public and private keypair from "ec_private_keys.json". It doesn't
// really matter which one is used since they are all valid. In this case
// using the first one.
- base::ListValue private_keys;
- ASSERT_TRUE(ReadJsonTestFileToList("ec_private_keys.json", &private_keys));
- const base::Value& key_value = private_keys.GetList()[0];
+ base::Value private_keys;
+ ASSERT_TRUE(ReadJsonTestFileAsList("ec_private_keys.json", &private_keys));
+ const base::Value& key_value = private_keys.GetListDeprecated()[0];
ASSERT_TRUE(key_value.is_dict());
const base::DictionaryValue* key_dict =
&base::Value::AsDictionaryValue(key_value);
@@ -115,7 +115,9 @@ TEST_F(WebCryptoEcdsaTest, SignatureIsRandom) {
// Erase the "d" member so the private key JWK can be used to import the
// public key (WebCrypto doesn't provide a mechanism for importing a public
// key given a private key).
- std::unique_ptr<base::DictionaryValue> key_jwk_copy(key_jwk->DeepCopy());
+ std::unique_ptr<base::DictionaryValue> key_jwk_copy =
+ base::DictionaryValue::From(
+ base::Value::ToUniquePtrValue(key_jwk->Clone()));
key_jwk_copy->RemoveKey("d");
blink::WebCryptoKey public_key;
ASSERT_EQ(
@@ -153,14 +155,14 @@ TEST_F(WebCryptoEcdsaTest, SignatureIsRandom) {
// Tests verify() for ECDSA using an assortment of keys, curves and hashes.
// These tests also include expected failures for bad signatures and keys.
TEST_F(WebCryptoEcdsaTest, VerifyKnownAnswer) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("ecdsa.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("ecdsa.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -227,7 +229,7 @@ blink::WebCryptoKeyUsageMask GetExpectedUsagesForKeyImport(
const base::DictionaryValue* key = nullptr;
if (!test->GetDictionary("key", &key))
ADD_FAILURE() << "Missing key property";
- return key->HasKey("d") ? kPrivateUsages : kPublicUsages;
+ return key->FindKey("d") ? kPrivateUsages : kPublicUsages;
}
}
@@ -237,14 +239,14 @@ blink::WebCryptoKeyUsageMask GetExpectedUsagesForKeyImport(
// Tests importing bad public/private keys in a variety of formats.
TEST_F(WebCryptoEcdsaTest, ImportBadKeys) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("bad_ec_keys.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("bad_ec_keys.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -270,14 +272,14 @@ TEST_F(WebCryptoEcdsaTest, ImportBadKeys) {
// The test imports a key first using JWK, and then exporting it to JWK and
// PKCS8. It does the same thing using PKCS8 as the original source of truth.
TEST_F(WebCryptoEcdsaTest, ImportExportPrivateKey) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("ec_private_keys.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("ec_private_keys.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -287,7 +289,7 @@ TEST_F(WebCryptoEcdsaTest, ImportExportPrivateKey) {
EXPECT_TRUE(test->GetDictionary("jwk", &jwk_dict));
std::vector<uint8_t> jwk_bytes = MakeJsonVector(*jwk_dict);
std::vector<uint8_t> pkcs8_bytes = GetBytesFromHexString(
- test, test->HasKey("exported_pkcs8") ? "exported_pkcs8" : "pkcs8");
+ test, test->FindKey("exported_pkcs8") ? "exported_pkcs8" : "pkcs8");
// -------------------------------------------------
// Test from JWK, and then export to {JWK, PKCS8}
@@ -335,7 +337,7 @@ TEST_F(WebCryptoEcdsaTest, ImportExportPrivateKey) {
// 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");
+ test, test->FindKey("original_pkcs8") ? "original_pkcs8" : "pkcs8");
CryptoData pkcs8_input_data(pkcs8_input_bytes.empty() ? pkcs8_bytes
: pkcs8_input_bytes);
diff --git a/chromium/components/webcrypto/algorithms/hmac_unittest.cc b/chromium/components/webcrypto/algorithms/hmac_unittest.cc
index 83c339847e1..7f16c1a63a3 100644
--- a/chromium/components/webcrypto/algorithms/hmac_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/hmac_unittest.cc
@@ -50,12 +50,12 @@ blink::WebCryptoAlgorithm CreateHmacImportAlgorithmWithLength(
class WebCryptoHmacTest : public WebCryptoTestBase {};
TEST_F(WebCryptoHmacTest, HMACSampleSets) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("hmac.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("hmac.json", &tests));
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/rsa_oaep_unittest.cc b/chromium/components/webcrypto/algorithms/rsa_oaep_unittest.cc
index 2de31a1ba79..eb8f8efd785 100644
--- a/chromium/components/webcrypto/algorithms/rsa_oaep_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/rsa_oaep_unittest.cc
@@ -155,14 +155,14 @@ TEST_F(WebCryptoRsaOaepTest, ExportPublicJwk) {
}
TEST_F(WebCryptoRsaOaepTest, EncryptDecryptKnownAnswerTest) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("rsa_oaep.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("rsa_oaep.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/rsa_pss_unittest.cc b/chromium/components/webcrypto/algorithms/rsa_pss_unittest.cc
index e5a8daa9ec6..f0cf03a7804 100644
--- a/chromium/components/webcrypto/algorithms/rsa_pss_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/rsa_pss_unittest.cc
@@ -166,20 +166,21 @@ TEST_F(WebCryptoRsaPssTest, SignEmptyMessage) {
// * Verify over corrupted message should fail
// * Verification with corrupted signature should fail
TEST_F(WebCryptoRsaPssTest, VerifyKnownAnswer) {
- base::DictionaryValue test_data;
- ASSERT_TRUE(ReadJsonTestFileToDictionary("rsa_pss.json", &test_data));
+ base::Value test_data;
+ ASSERT_TRUE(ReadJsonTestFile("rsa_pss.json", &test_data));
+ ASSERT_TRUE(test_data.is_dict());
- const base::DictionaryValue* keys_dict = nullptr;
- ASSERT_TRUE(test_data.GetDictionary("keys", &keys_dict));
+ const base::Value* keys_dict = test_data.FindDictKey("keys");
+ ASSERT_TRUE(keys_dict);
- const base::ListValue* tests = nullptr;
- ASSERT_TRUE(test_data.GetList("tests", &tests));
+ const base::Value* tests = test_data.FindListKey("tests");
+ ASSERT_TRUE(tests);
- for (size_t test_index = 0; test_index < tests->GetList().size();
+ for (size_t test_index = 0; test_index < tests->GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests->GetList()[test_index];
+ const base::Value& test_value = tests->GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/rsa_ssa_unittest.cc b/chromium/components/webcrypto/algorithms/rsa_ssa_unittest.cc
index 5ebf78a6fb7..04834eab833 100644
--- a/chromium/components/webcrypto/algorithms/rsa_ssa_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/rsa_ssa_unittest.cc
@@ -202,18 +202,18 @@ TEST_F(WebCryptoRsaSsaTest, ImportRsaPrivateKeyJwkToPkcs8RoundTrip) {
// be imported correctly, however every key after that would actually import
// the first key.
TEST_F(WebCryptoRsaSsaTest, ImportMultipleRSAPrivateKeysJwk) {
- base::ListValue key_list;
- ASSERT_TRUE(ReadJsonTestFileToList("rsa_private_keys.json", &key_list));
+ base::Value key_list;
+ ASSERT_TRUE(ReadJsonTestFileAsList("rsa_private_keys.json", &key_list));
// For this test to be meaningful the keys MUST be kept alive before importing
// new keys.
std::vector<blink::WebCryptoKey> live_keys;
- for (size_t key_index = 0; key_index < key_list.GetList().size();
+ for (size_t key_index = 0; key_index < key_list.GetListDeprecated().size();
++key_index) {
SCOPED_TRACE(key_index);
- const base::Value& key_values = key_list.GetList()[key_index];
+ const base::Value& key_values = key_list.GetListDeprecated()[key_index];
ASSERT_TRUE(key_values.is_dict());
const base::DictionaryValue* key_values_dict =
&base::Value::AsDictionaryValue(key_values);
@@ -264,11 +264,11 @@ TEST_F(WebCryptoRsaSsaTest, ImportMultipleRSAPrivateKeysJwk) {
// that the second import retrieves the first key. See http://crbug.com/378315
// for how that could happen.
TEST_F(WebCryptoRsaSsaTest, ImportJwkExistingModulusAndInvalid) {
- base::ListValue key_list;
- ASSERT_TRUE(ReadJsonTestFileToList("rsa_private_keys.json", &key_list));
+ base::Value key_list;
+ ASSERT_TRUE(ReadJsonTestFileAsList("rsa_private_keys.json", &key_list));
// Import a 1024-bit private key.
- const base::Value& key1_props_value = key_list.GetList()[1];
+ const base::Value& key1_props_value = key_list.GetListDeprecated()[1];
ASSERT_TRUE(key1_props_value.is_dict());
const base::DictionaryValue* key1_props =
&base::Value::AsDictionaryValue(key1_props_value);
@@ -288,7 +288,7 @@ TEST_F(WebCryptoRsaSsaTest, ImportJwkExistingModulusAndInvalid) {
// Construct a JWK using the modulus of key1, but all the other fields from
// another key (also a 1024-bit private key).
- base::Value& key2_props_value = key_list.GetList()[5];
+ base::Value& key2_props_value = key_list.GetListDeprecated()[5];
ASSERT_TRUE(key2_props_value.is_dict());
base::DictionaryValue* key2_props = const_cast<base::DictionaryValue*>(
&base::Value::AsDictionaryValue(key2_props_value));
@@ -639,8 +639,8 @@ TEST_F(WebCryptoRsaSsaTest, SignVerifyFailures) {
}
TEST_F(WebCryptoRsaSsaTest, SignVerifyKnownAnswer) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("pkcs1v15_sign.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("pkcs1v15_sign.json", &tests));
// Import the key pair.
blink::WebCryptoAlgorithm import_algorithm = CreateRsaHashedImportAlgorithm(
@@ -659,11 +659,11 @@ TEST_F(WebCryptoRsaSsaTest, SignVerifyKnownAnswer) {
// Validate the signatures are computed and verified as expected.
std::vector<uint8_t> signature;
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
@@ -997,14 +997,14 @@ TEST_F(WebCryptoRsaSsaTest, ImportRsaSsaJwkBadUsageAndData) {
// Imports invalid JWK/SPKI/PKCS8 data and verifies that it fails as expected.
TEST_F(WebCryptoRsaSsaTest, ImportInvalidKeyData) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("bad_rsa_keys.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("bad_rsa_keys.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/sha_unittest.cc b/chromium/components/webcrypto/algorithms/sha_unittest.cc
index 613fd61a7ed..cec19aa30fb 100644
--- a/chromium/components/webcrypto/algorithms/sha_unittest.cc
+++ b/chromium/components/webcrypto/algorithms/sha_unittest.cc
@@ -22,13 +22,13 @@ namespace {
class WebCryptoShaTest : public WebCryptoTestBase {};
TEST_F(WebCryptoShaTest, DigestSampleSets) {
- base::ListValue tests;
- ASSERT_TRUE(ReadJsonTestFileToList("sha.json", &tests));
+ base::Value tests;
+ ASSERT_TRUE(ReadJsonTestFileAsList("sha.json", &tests));
- for (size_t test_index = 0; test_index < tests.GetList().size();
+ for (size_t test_index = 0; test_index < tests.GetListDeprecated().size();
++test_index) {
SCOPED_TRACE(test_index);
- const base::Value& test_value = tests.GetList()[test_index];
+ const base::Value& test_value = tests.GetListDeprecated()[test_index];
ASSERT_TRUE(test_value.is_dict());
const base::DictionaryValue* test =
&base::Value::AsDictionaryValue(test_value);
diff --git a/chromium/components/webcrypto/algorithms/test_helpers.cc b/chromium/components/webcrypto/algorithms/test_helpers.cc
index 6f6be59a140..87e2f54d373 100644
--- a/chromium/components/webcrypto/algorithms/test_helpers.cc
+++ b/chromium/components/webcrypto/algorithms/test_helpers.cc
@@ -172,50 +172,35 @@ std::vector<uint8_t> MakeJsonVector(const base::DictionaryValue& dict) {
return ::testing::AssertionSuccess();
}
-::testing::AssertionResult ReadJsonTestFileToList(const char* test_file_name,
- base::ListValue* list) {
+::testing::AssertionResult ReadJsonTestFileAsList(const char* test_file_name,
+ base::Value* value) {
// Read the JSON.
base::Value json;
::testing::AssertionResult result = ReadJsonTestFile(test_file_name, &json);
if (!result)
return result;
- // Cast to an ListValue.
- base::ListValue* json_as_list = nullptr;
- if (!json.GetAsList(&json_as_list))
+ if (!json.is_list())
return ::testing::AssertionFailure() << "The JSON was not a list";
- *list = std::move(*json_as_list);
+ *value = std::move(json);
return ::testing::AssertionSuccess();
}
-::testing::AssertionResult ReadJsonTestFileToDictionary(
- const char* test_file_name,
- base::DictionaryValue* dict) {
- // Read the JSON.
- base::Value json;
- ::testing::AssertionResult result = ReadJsonTestFile(test_file_name, &json);
- if (!result)
- return result;
-
- // Cast to an DictionaryValue.
- base::DictionaryValue* json_as_dict = nullptr;
- if (!json.GetAsDictionary(&json_as_dict))
- return ::testing::AssertionFailure() << "The JSON was not a dictionary";
-
- *dict = std::move(*json_as_dict);
- return ::testing::AssertionSuccess();
-}
-
-std::vector<uint8_t> GetBytesFromHexString(const base::DictionaryValue* dict,
+std::vector<uint8_t> GetBytesFromHexString(const base::Value* dict,
const std::string& property_name) {
- std::string hex_string;
- if (!dict->GetString(property_name, &hex_string)) {
+ if (!dict->is_dict()) {
+ ADD_FAILURE() << "Value is not a dictionary";
+ return std::vector<uint8_t>();
+ }
+
+ const std::string* hex_string = dict->FindStringPath(property_name);
+ if (!hex_string) {
ADD_FAILURE() << "Couldn't get string property: " << property_name;
return std::vector<uint8_t>();
}
- return HexStringToBytes(hex_string);
+ return HexStringToBytes(*hex_string);
}
blink::WebCryptoAlgorithm GetDigestAlgorithm(const base::DictionaryValue* dict,
diff --git a/chromium/components/webcrypto/algorithms/test_helpers.h b/chromium/components/webcrypto/algorithms/test_helpers.h
index 40296348bc9..ea06d625500 100644
--- a/chromium/components/webcrypto/algorithms/test_helpers.h
+++ b/chromium/components/webcrypto/algorithms/test_helpers.h
@@ -25,7 +25,6 @@
namespace base {
class DictionaryValue;
-class ListValue;
class Value;
}
@@ -86,20 +85,16 @@ std::vector<uint8_t> MakeJsonVector(const base::DictionaryValue& dict);
// The file must be JSON, however it can also include C++ style comments.
::testing::AssertionResult ReadJsonTestFile(const char* test_file_name,
base::Value* value);
-// Same as ReadJsonTestFile(), but returns the value as a List.
-::testing::AssertionResult ReadJsonTestFileToList(const char* test_file_name,
- base::ListValue* list);
-// Same as ReadJsonTestFile(), but returns the value as a Dictionary.
-::testing::AssertionResult ReadJsonTestFileToDictionary(
- const char* test_file_name,
- base::DictionaryValue* dict);
-
-// Reads a string property from the dictionary with path |property_name|
+// Same as ReadJsonTestFile(), but asserts the value is a list.
+::testing::AssertionResult ReadJsonTestFileAsList(const char* test_file_name,
+ base::Value* list);
+
+// Reads a string property from the dictionary |dict| with path |property_name|
// (which can include periods for nested dictionaries). Interprets the
// string as a hex encoded string and converts it to a bytes list.
//
-// Returns empty vector on failure.
-std::vector<uint8_t> GetBytesFromHexString(const base::DictionaryValue* dict,
+// Returns empty vector on failure or if |dict| is not a dictionary.
+std::vector<uint8_t> GetBytesFromHexString(const base::Value* dict,
const std::string& property_name);
// Reads a string property with path "property_name" and converts it to a
diff --git a/chromium/components/webcrypto/jwk.cc b/chromium/components/webcrypto/jwk.cc
index 14d535e556a..857865368b7 100644
--- a/chromium/components/webcrypto/jwk.cc
+++ b/chromium/components/webcrypto/jwk.cc
@@ -114,7 +114,7 @@ Status GetWebCryptoUsagesFromJwkKeyOps(const base::ListValue* key_ops,
std::set<std::string> unrecognized_usages;
*usages = 0;
- base::Value::ConstListView key_ops_list = key_ops->GetList();
+ base::Value::ConstListView key_ops_list = key_ops->GetListDeprecated();
for (size_t i = 0; i < key_ops_list.size(); ++i) {
const base::Value& key_op_value = key_ops_list[i];
if (!key_op_value.is_string()) {