| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 blink::WebCryptoKey ImportSecretKeyFromRaw( | 123 blink::WebCryptoKey ImportSecretKeyFromRaw( |
| 124 const std::vector<uint8_t>& key_raw, | 124 const std::vector<uint8_t>& key_raw, |
| 125 const blink::WebCryptoAlgorithm& algorithm, | 125 const blink::WebCryptoAlgorithm& algorithm, |
| 126 blink::WebCryptoKeyUsageMask usage); | 126 blink::WebCryptoKeyUsageMask usage); |
| 127 | 127 |
| 128 void ImportRsaKeyPair(const std::vector<uint8_t>& spki_der, | 128 void ImportRsaKeyPair(const std::vector<uint8_t>& spki_der, |
| 129 const std::vector<uint8_t>& pkcs8_der, | 129 const std::vector<uint8_t>& pkcs8_der, |
| 130 const blink::WebCryptoAlgorithm& algorithm, | 130 const blink::WebCryptoAlgorithm& algorithm, |
| 131 bool extractable, | 131 bool extractable, |
| 132 blink::WebCryptoKeyUsageMask public_key_usage_mask, | 132 blink::WebCryptoKeyUsageMask public_key_usages, |
| 133 blink::WebCryptoKeyUsageMask private_key_usage_mask, | 133 blink::WebCryptoKeyUsageMask private_key_usages, |
| 134 blink::WebCryptoKey* public_key, | 134 blink::WebCryptoKey* public_key, |
| 135 blink::WebCryptoKey* private_key); | 135 blink::WebCryptoKey* private_key); |
| 136 | 136 |
| 137 Status ImportKeyJwkFromDict(const base::DictionaryValue& dict, | 137 Status ImportKeyJwkFromDict(const base::DictionaryValue& dict, |
| 138 const blink::WebCryptoAlgorithm& algorithm, | 138 const blink::WebCryptoAlgorithm& algorithm, |
| 139 bool extractable, | 139 bool extractable, |
| 140 blink::WebCryptoKeyUsageMask usage_mask, | 140 blink::WebCryptoKeyUsageMask usages, |
| 141 blink::WebCryptoKey* key); | 141 blink::WebCryptoKey* key); |
| 142 | 142 |
| 143 // Parses a vector of JSON into a dictionary. | 143 // Parses a vector of JSON into a dictionary. |
| 144 scoped_ptr<base::DictionaryValue> GetJwkDictionary( | 144 scoped_ptr<base::DictionaryValue> GetJwkDictionary( |
| 145 const std::vector<uint8_t>& json); | 145 const std::vector<uint8_t>& json); |
| 146 | 146 |
| 147 // Verifies the input dictionary contains the expected values. Exact matches are | 147 // Verifies the input dictionary contains the expected values. Exact matches are |
| 148 // required on the fields examined. | 148 // required on the fields examined. |
| 149 ::testing::AssertionResult VerifyJwk( | 149 ::testing::AssertionResult VerifyJwk( |
| 150 const scoped_ptr<base::DictionaryValue>& dict, | 150 const scoped_ptr<base::DictionaryValue>& dict, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 172 int key_len_bits, | 172 int key_len_bits, |
| 173 const blink::WebCryptoAlgorithm& import_algorithm, | 173 const blink::WebCryptoAlgorithm& import_algorithm, |
| 174 blink::WebCryptoKeyUsageMask usages, | 174 blink::WebCryptoKeyUsageMask usages, |
| 175 const std::string& jwk_alg); | 175 const std::string& jwk_alg); |
| 176 | 176 |
| 177 // Wrappers around GenerateKey() which expect the result to be either a secret | 177 // Wrappers around GenerateKey() which expect the result to be either a secret |
| 178 // key or a public/private keypair. If the result does not match the | 178 // key or a public/private keypair. If the result does not match the |
| 179 // expectation, then it fails with Status::ErrorUnexpected(). | 179 // expectation, then it fails with Status::ErrorUnexpected(). |
| 180 Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, | 180 Status GenerateSecretKey(const blink::WebCryptoAlgorithm& algorithm, |
| 181 bool extractable, | 181 bool extractable, |
| 182 blink::WebCryptoKeyUsageMask usage_mask, | 182 blink::WebCryptoKeyUsageMask usages, |
| 183 blink::WebCryptoKey* key); | 183 blink::WebCryptoKey* key); |
| 184 Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, | 184 Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm, |
| 185 bool extractable, | 185 bool extractable, |
| 186 blink::WebCryptoKeyUsageMask usage_mask, | 186 blink::WebCryptoKeyUsageMask usages, |
| 187 blink::WebCryptoKey* public_key, | 187 blink::WebCryptoKey* public_key, |
| 188 blink::WebCryptoKey* private_key); | 188 blink::WebCryptoKey* private_key); |
| 189 | 189 |
| 190 } // namespace webcrypto | 190 } // namespace webcrypto |
| 191 | 191 |
| 192 } // namesapce content | 192 } // namesapce content |
| 193 | 193 |
| 194 #endif // CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ | 194 #endif // CONTENT_CHILD_WEBCRYPTO_TEST_TEST_HELPERS_H_ |
| OLD | NEW |