| Index: content/child/webcrypto/webcrypto_impl.cc
|
| diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc
|
| index 8efd9de0fb141ab748065944c173899f72c3be38..9a3924b9aa9d9047654cf59e5e07dde5133a49a4 100644
|
| --- a/content/child/webcrypto/webcrypto_impl.cc
|
| +++ b/content/child/webcrypto/webcrypto_impl.cc
|
| @@ -350,6 +350,32 @@ struct DeriveBitsState : public BaseState {
|
| std::vector<uint8_t> derived_bytes;
|
| };
|
|
|
| +struct DeriveKeyState : public BaseState {
|
| + DeriveKeyState(const blink::WebCryptoAlgorithm& algorithm,
|
| + const blink::WebCryptoKey& base_key,
|
| + const blink::WebCryptoAlgorithm& import_algorithm,
|
| + const blink::WebCryptoAlgorithm& key_length_algorithm,
|
| + bool extractable,
|
| + blink::WebCryptoKeyUsageMask usages,
|
| + const blink::WebCryptoResult& result)
|
| + : BaseState(result),
|
| + algorithm(algorithm),
|
| + base_key(base_key),
|
| + import_algorithm(import_algorithm),
|
| + key_length_algorithm(key_length_algorithm),
|
| + extractable(extractable),
|
| + usages(usages) {}
|
| +
|
| + const blink::WebCryptoAlgorithm algorithm;
|
| + const blink::WebCryptoKey base_key;
|
| + const blink::WebCryptoAlgorithm import_algorithm;
|
| + const blink::WebCryptoAlgorithm key_length_algorithm;
|
| + bool extractable;
|
| + blink::WebCryptoKeyUsageMask usages;
|
| +
|
| + blink::WebCryptoKey derived_key;
|
| +};
|
| +
|
| // --------------------------------------------------------------------
|
| // Wrapper functions
|
| // --------------------------------------------------------------------
|
| @@ -552,6 +578,22 @@ void DoDeriveBits(scoped_ptr<DeriveBitsState> passed_state) {
|
| FROM_HERE, base::Bind(DoDeriveBitsReply, Passed(&passed_state)));
|
| }
|
|
|
| +void DoDeriveKeyReply(scoped_ptr<DeriveKeyState> state) {
|
| + CompleteWithKeyOrError(state->status, state->derived_key, &state->result);
|
| +}
|
| +
|
| +void DoDeriveKey(scoped_ptr<DeriveKeyState> passed_state) {
|
| + DeriveKeyState* state = passed_state.get();
|
| + if (state->cancelled())
|
| + return;
|
| + state->status = webcrypto::DeriveKey(
|
| + state->algorithm, state->base_key, state->import_algorithm,
|
| + state->key_length_algorithm, state->extractable, state->usages,
|
| + &state->derived_key);
|
| + state->origin_thread->PostTask(
|
| + FROM_HERE, base::Bind(DoDeriveKeyReply, Passed(&passed_state)));
|
| +}
|
| +
|
| } // namespace
|
|
|
| WebCryptoImpl::WebCryptoImpl() {
|
| @@ -715,6 +757,23 @@ void WebCryptoImpl::deriveBits(const blink::WebCryptoAlgorithm& algorithm,
|
| }
|
| }
|
|
|
| +void WebCryptoImpl::deriveKey(
|
| + const blink::WebCryptoAlgorithm& algorithm,
|
| + const blink::WebCryptoKey& base_key,
|
| + const blink::WebCryptoAlgorithm& import_algorithm,
|
| + const blink::WebCryptoAlgorithm& key_length_algorithm,
|
| + bool extractable,
|
| + blink::WebCryptoKeyUsageMask usages,
|
| + blink::WebCryptoResult result) {
|
| + scoped_ptr<DeriveKeyState> state(
|
| + new DeriveKeyState(algorithm, base_key, import_algorithm,
|
| + key_length_algorithm, extractable, usages, result));
|
| + if (!CryptoThreadPool::PostTask(FROM_HERE,
|
| + base::Bind(DoDeriveKey, Passed(&state)))) {
|
| + CompleteWithThreadPoolError(&result);
|
| + }
|
| +}
|
| +
|
| blink::WebCryptoDigestor* WebCryptoImpl::createDigestor(
|
| blink::WebCryptoAlgorithmId algorithm_id) {
|
| return webcrypto::CreateDigestor(algorithm_id).release();
|
|
|