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

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

Issue 661653002: [webcrypto] Implement RSA-PSS using BoringSSL. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_rsassa
Patch Set: Add some tests from fips 186-2, covering sha-{256, 384, 512} Created 6 years, 2 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/test_helpers.cc
diff --git a/content/child/webcrypto/test/test_helpers.cc b/content/child/webcrypto/test/test_helpers.cc
index fa45f4d78df86adc3e686e36b3384a002efeafe8..1507cd2e2b99f41d58cf361f7601e45684d22532 100644
--- a/content/child/webcrypto/test/test_helpers.cc
+++ b/content/child/webcrypto/test/test_helpers.cc
@@ -120,8 +120,6 @@ blink::WebCryptoAlgorithm CreateRsaHashedKeyGenAlgorithm(
const blink::WebCryptoAlgorithmId hash_id,
unsigned int modulus_length,
const std::vector<uint8_t>& public_exponent) {
- DCHECK(algorithm_id == blink::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
- algorithm_id == blink::WebCryptoAlgorithmIdRsaOaep);
DCHECK(blink::WebCryptoAlgorithm::isHash(hash_id));
return blink::WebCryptoAlgorithm::adoptParamsAndCreate(
algorithm_id,
@@ -205,8 +203,28 @@ std::vector<uint8_t> MakeJsonVector(const base::DictionaryValue& dict) {
return ::testing::AssertionSuccess();
}
-std::vector<uint8_t> GetBytesFromHexString(base::DictionaryValue* dict,
- const char* property_name) {
+::testing::AssertionResult ReadJsonTestFileToDictionary(
+ const char* test_file_name,
+ scoped_ptr<base::DictionaryValue>* dict) {
+ // Read the JSON.
+ scoped_ptr<base::Value> json;
+ ::testing::AssertionResult result = ReadJsonTestFile(test_file_name, &json);
+ if (!result)
+ return result;
+
+ // Cast to an DictionaryValue.
+ base::DictionaryValue* dict_value = NULL;
+ if (!json->GetAsDictionary(&dict_value) || !dict_value)
+ return ::testing::AssertionFailure() << "The JSON was not a dictionary";
+
+ dict->reset(dict_value);
+ ignore_result(json.release());
+
+ return ::testing::AssertionSuccess();
+}
+
+std::vector<uint8_t> GetBytesFromHexString(const base::DictionaryValue* dict,
+ const std::string& property_name) {
std::string hex_string;
if (!dict->GetString(property_name, &hex_string)) {
EXPECT_TRUE(false) << "Couldn't get string property: " << property_name;
@@ -216,7 +234,7 @@ std::vector<uint8_t> GetBytesFromHexString(base::DictionaryValue* dict,
return HexStringToBytes(hex_string);
}
-blink::WebCryptoAlgorithm GetDigestAlgorithm(base::DictionaryValue* dict,
+blink::WebCryptoAlgorithm GetDigestAlgorithm(const base::DictionaryValue* dict,
const char* property_name) {
std::string algorithm_name;
if (!dict->GetString(property_name, &algorithm_name)) {

Powered by Google App Engine
This is Rietveld 408576698