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 #include "content/child/webcrypto/webcrypto_impl.h" | 5 #include "content/child/webcrypto/webcrypto_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" |
8 #include "content/child/webcrypto/crypto_data.h" | 9 #include "content/child/webcrypto/crypto_data.h" |
9 #include "content/child/webcrypto/shared_crypto.h" | 10 #include "content/child/webcrypto/shared_crypto.h" |
10 #include "content/child/webcrypto/status.h" | 11 #include "content/child/webcrypto/status.h" |
11 #include "content/child/webcrypto/webcrypto_util.h" | 12 #include "content/child/webcrypto/webcrypto_util.h" |
12 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 13 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 14 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 using webcrypto::Status; | 18 using webcrypto::Status; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const unsigned char* data, | 242 const unsigned char* data, |
242 unsigned int data_size, | 243 unsigned int data_size, |
243 blink::WebArrayBuffer& result) { | 244 blink::WebArrayBuffer& result) { |
244 blink::WebCryptoAlgorithm algorithm = | 245 blink::WebCryptoAlgorithm algorithm = |
245 blink::WebCryptoAlgorithm::adoptParamsAndCreate(algorithm_id, NULL); | 246 blink::WebCryptoAlgorithm::adoptParamsAndCreate(algorithm_id, NULL); |
246 return (webcrypto::Digest( | 247 return (webcrypto::Digest( |
247 algorithm, webcrypto::CryptoData(data, data_size), &result)) | 248 algorithm, webcrypto::CryptoData(data, data_size), &result)) |
248 .IsSuccess(); | 249 .IsSuccess(); |
249 } | 250 } |
250 | 251 |
| 252 blink::WebCryptoDigestor* WebCryptoImpl::createDigestor( |
| 253 const blink::WebCryptoAlgorithmId algorithm_id) { |
| 254 return webcrypto::CreateDigestor(algorithm_id).release(); |
| 255 } |
| 256 |
251 bool WebCryptoImpl::deserializeKeyForClone( | 257 bool WebCryptoImpl::deserializeKeyForClone( |
252 const blink::WebCryptoKeyAlgorithm& algorithm, | 258 const blink::WebCryptoKeyAlgorithm& algorithm, |
253 blink::WebCryptoKeyType type, | 259 blink::WebCryptoKeyType type, |
254 bool extractable, | 260 bool extractable, |
255 blink::WebCryptoKeyUsageMask usages, | 261 blink::WebCryptoKeyUsageMask usages, |
256 const unsigned char* key_data, | 262 const unsigned char* key_data, |
257 unsigned key_data_size, | 263 unsigned key_data_size, |
258 blink::WebCryptoKey& key) { | 264 blink::WebCryptoKey& key) { |
259 Status status = webcrypto::DeserializeKeyForClone( | 265 Status status = webcrypto::DeserializeKeyForClone( |
260 algorithm, | 266 algorithm, |
261 type, | 267 type, |
262 extractable, | 268 extractable, |
263 usages, | 269 usages, |
264 webcrypto::CryptoData(key_data, key_data_size), | 270 webcrypto::CryptoData(key_data, key_data_size), |
265 &key); | 271 &key); |
266 return status.IsSuccess(); | 272 return status.IsSuccess(); |
267 } | 273 } |
268 | 274 |
269 bool WebCryptoImpl::serializeKeyForClone( | 275 bool WebCryptoImpl::serializeKeyForClone( |
270 const blink::WebCryptoKey& key, | 276 const blink::WebCryptoKey& key, |
271 blink::WebVector<unsigned char>& key_data) { | 277 blink::WebVector<unsigned char>& key_data) { |
272 Status status = webcrypto::SerializeKeyForClone(key, &key_data); | 278 Status status = webcrypto::SerializeKeyForClone(key, &key_data); |
273 return status.IsSuccess(); | 279 return status.IsSuccess(); |
274 } | 280 } |
275 | 281 |
276 } // namespace content | 282 } // namespace content |
OLD | NEW |