| OLD | NEW |
| 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 #ifndef CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ |
| 7 | 7 |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // ---------------------------------------------------------------- | 76 // ---------------------------------------------------------------- |
| 77 | 77 |
| 78 // Reads a file in "src/content/test/data/webcrypto" to a base::Value. | 78 // Reads a file in "src/content/test/data/webcrypto" to a base::Value. |
| 79 // The file must be JSON, however it can also include C++ style comments. | 79 // The file must be JSON, however it can also include C++ style comments. |
| 80 ::testing::AssertionResult ReadJsonTestFile(const char* test_file_name, | 80 ::testing::AssertionResult ReadJsonTestFile(const char* test_file_name, |
| 81 scoped_ptr<base::Value>* value); | 81 scoped_ptr<base::Value>* value); |
| 82 // Same as ReadJsonTestFile(), but returns the value as a List. | 82 // Same as ReadJsonTestFile(), but returns the value as a List. |
| 83 ::testing::AssertionResult ReadJsonTestFileToList( | 83 ::testing::AssertionResult ReadJsonTestFileToList( |
| 84 const char* test_file_name, | 84 const char* test_file_name, |
| 85 scoped_ptr<base::ListValue>* list); | 85 scoped_ptr<base::ListValue>* list); |
| 86 // Same as ReadJsonTestFile(), but returns the value as a Dictionary. |
| 87 ::testing::AssertionResult ReadJsonTestFileToDictionary( |
| 88 const char* test_file_name, |
| 89 scoped_ptr<base::DictionaryValue>* dict); |
| 86 | 90 |
| 87 // Reads a string property from the dictionary with path |property_name| | 91 // Reads a string property from the dictionary with path |property_name| |
| 88 // (which can include periods for nested dictionaries). Interprets the | 92 // (which can include periods for nested dictionaries). Interprets the |
| 89 // string as a hex encoded string and converts it to a bytes list. | 93 // string as a hex encoded string and converts it to a bytes list. |
| 90 // | 94 // |
| 91 // Returns empty vector on failure. | 95 // Returns empty vector on failure. |
| 92 std::vector<uint8_t> GetBytesFromHexString(base::DictionaryValue* dict, | 96 std::vector<uint8_t> GetBytesFromHexString(const base::DictionaryValue* dict, |
| 93 const char* property_name); | 97 const std::string& property_name); |
| 94 | 98 |
| 95 // Reads a string property with path "property_name" and converts it to a | 99 // Reads a string property with path "property_name" and converts it to a |
| 96 // WebCryptoAlgorith. Returns null algorithm on failure. | 100 // WebCryptoAlgorith. Returns null algorithm on failure. |
| 97 blink::WebCryptoAlgorithm GetDigestAlgorithm(base::DictionaryValue* dict, | 101 blink::WebCryptoAlgorithm GetDigestAlgorithm(const base::DictionaryValue* dict, |
| 98 const char* property_name); | 102 const char* property_name); |
| 99 | 103 |
| 100 // Returns true if any of the vectors in the input list have identical content. | 104 // Returns true if any of the vectors in the input list have identical content. |
| 101 bool CopiesExist(const std::vector<std::vector<uint8_t> >& bufs); | 105 bool CopiesExist(const std::vector<std::vector<uint8_t> >& bufs); |
| 102 | 106 |
| 103 blink::WebCryptoAlgorithm CreateAesKeyGenAlgorithm( | 107 blink::WebCryptoAlgorithm CreateAesKeyGenAlgorithm( |
| 104 blink::WebCryptoAlgorithmId aes_alg_id, | 108 blink::WebCryptoAlgorithmId aes_alg_id, |
| 105 unsigned short length); | 109 unsigned short length); |
| 106 | 110 |
| 107 // The following key pair is comprised of the SPKI (public key) and PKCS#8 | 111 // The following key pair is comprised of the SPKI (public key) and PKCS#8 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 int key_len_bits, | 172 int key_len_bits, |
| 169 const blink::WebCryptoAlgorithm& import_algorithm, | 173 const blink::WebCryptoAlgorithm& import_algorithm, |
| 170 blink::WebCryptoKeyUsageMask usages, | 174 blink::WebCryptoKeyUsageMask usages, |
| 171 const std::string& jwk_alg); | 175 const std::string& jwk_alg); |
| 172 | 176 |
| 173 } // namespace webcrypto | 177 } // namespace webcrypto |
| 174 | 178 |
| 175 } // namesapce content | 179 } // namesapce content |
| 176 | 180 |
| 177 #endif // CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ | 181 #endif // CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ |
| OLD | NEW |