| Index: content/child/webcrypto/webcrypto_impl.cc
|
| diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc
|
| index e367ae641b011de7ad3a5c2197f8d5bb392b38ba..418c0f81f2bd9f8abdb0c46ef3a94f2358a67441 100644
|
| --- a/content/child/webcrypto/webcrypto_impl.cc
|
| +++ b/content/child/webcrypto/webcrypto_impl.cc
|
| @@ -17,6 +17,7 @@
|
| #include "base/threading/worker_pool.h"
|
| #include "content/child/webcrypto/algorithm_dispatch.h"
|
| #include "content/child/webcrypto/crypto_data.h"
|
| +#include "content/child/webcrypto/generate_key_result.h"
|
| #include "content/child/webcrypto/status.h"
|
| #include "content/child/webcrypto/structured_clone.h"
|
| #include "content/child/webcrypto/webcrypto_util.h"
|
| @@ -215,20 +216,13 @@ struct GenerateKeyState : public BaseState {
|
| : BaseState(result),
|
| algorithm(algorithm),
|
| extractable(extractable),
|
| - usage_mask(usage_mask),
|
| - public_key(blink::WebCryptoKey::createNull()),
|
| - private_key(blink::WebCryptoKey::createNull()),
|
| - is_asymmetric(false) {}
|
| + usage_mask(usage_mask) {}
|
|
|
| const blink::WebCryptoAlgorithm algorithm;
|
| const bool extractable;
|
| const blink::WebCryptoKeyUsageMask usage_mask;
|
|
|
| - // If |is_asymmetric| is false, then |public_key| is understood to mean the
|
| - // symmetric key, and |private_key| is unused.
|
| - blink::WebCryptoKey public_key;
|
| - blink::WebCryptoKey private_key;
|
| - bool is_asymmetric;
|
| + webcrypto::GenerateKeyResult generate_key_result;
|
| };
|
|
|
| struct ImportKeyState : public BaseState {
|
| @@ -401,10 +395,7 @@ void DoGenerateKeyReply(scoped_ptr<GenerateKeyState> state) {
|
| if (state->status.IsError()) {
|
| CompleteWithError(state->status, &state->result);
|
| } else {
|
| - if (state->is_asymmetric)
|
| - state->result.completeWithKeyPair(state->public_key, state->private_key);
|
| - else
|
| - state->result.completeWithKey(state->public_key);
|
| + state->generate_key_result.Complete(&state->result);
|
| }
|
| }
|
|
|
| @@ -412,37 +403,10 @@ void DoGenerateKey(scoped_ptr<GenerateKeyState> passed_state) {
|
| GenerateKeyState* state = passed_state.get();
|
| if (state->cancelled())
|
| return;
|
| - state->is_asymmetric =
|
| - webcrypto::IsAlgorithmAsymmetric(state->algorithm.id());
|
| - if (state->is_asymmetric) {
|
| - state->status = webcrypto::GenerateKeyPair(state->algorithm,
|
| - state->extractable,
|
| - state->usage_mask,
|
| - &state->public_key,
|
| - &state->private_key);
|
| -
|
| - if (state->status.IsSuccess()) {
|
| - DCHECK(state->public_key.handle());
|
| - DCHECK(state->private_key.handle());
|
| - DCHECK_EQ(state->algorithm.id(), state->public_key.algorithm().id());
|
| - DCHECK_EQ(state->algorithm.id(), state->private_key.algorithm().id());
|
| - DCHECK_EQ(true, state->public_key.extractable());
|
| - DCHECK_EQ(state->extractable, state->private_key.extractable());
|
| - }
|
| - } else {
|
| - blink::WebCryptoKey* key = &state->public_key;
|
| -
|
| - state->status = webcrypto::GenerateSecretKey(
|
| - state->algorithm, state->extractable, state->usage_mask, key);
|
| -
|
| - if (state->status.IsSuccess()) {
|
| - DCHECK(key->handle());
|
| - DCHECK_EQ(state->algorithm.id(), key->algorithm().id());
|
| - DCHECK_EQ(state->extractable, key->extractable());
|
| - DCHECK_EQ(state->usage_mask, key->usages());
|
| - }
|
| - }
|
| -
|
| + state->status = webcrypto::GenerateKey(state->algorithm,
|
| + state->extractable,
|
| + state->usage_mask,
|
| + &state->generate_key_result);
|
| state->origin_thread->PostTask(
|
| FROM_HERE, base::Bind(DoGenerateKeyReply, Passed(&passed_state)));
|
| }
|
|
|