| Index: content/renderer/webcrypto/webcrypto_impl.cc
|
| diff --git a/content/renderer/webcrypto/webcrypto_impl.cc b/content/renderer/webcrypto/webcrypto_impl.cc
|
| index f2510100eb755c3f7d4b7929c6227a4bb7571a67..a42cd6eeaef8fea09a9ee9d1c720a3a669119a9c 100644
|
| --- a/content/renderer/webcrypto/webcrypto_impl.cc
|
| +++ b/content/renderer/webcrypto/webcrypto_impl.cc
|
| @@ -12,6 +12,19 @@
|
|
|
| namespace content {
|
|
|
| +namespace {
|
| +
|
| +bool IsAlgorithmAsymmetric(const WebKit::WebCryptoAlgorithm& algorithm) {
|
| + const WebKit::WebCryptoAlgorithmId algorithm_id = algorithm.id();
|
| + // TODO(padolph): include all other asymmetric algorithms once they are
|
| + // defined, e.g. EC and DH.
|
| + return (algorithm_id == WebKit::WebCryptoAlgorithmIdRsaEsPkcs1v1_5 ||
|
| + algorithm_id == WebKit::WebCryptoAlgorithmIdRsaSsaPkcs1v1_5 ||
|
| + algorithm_id == WebKit::WebCryptoAlgorithmIdRsaOaep);
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| WebCryptoImpl::WebCryptoImpl() {
|
| Init();
|
| }
|
| @@ -80,16 +93,40 @@ void WebCryptoImpl::generateKey(
|
| bool exportable,
|
| WebKit::WebCryptoKeyUsageMask usage,
|
| WebKit::WebCryptoResult result) {
|
| + if (IsAlgorithmAsymmetric(algorithm)) {
|
| + scoped_ptr<WebKit::WebCryptoKeyHandle> public_key_handle;
|
| + scoped_ptr<WebKit::WebCryptoKeyHandle> private_key_handle;
|
| + if (!GenerateKeyPairInternal(algorithm,
|
| + &public_key_handle,
|
| + &private_key_handle)) {
|
| + result.completeWithError();
|
| + return;
|
| + }
|
| + WebKit::WebCryptoKey public_key(
|
| + WebKit::WebCryptoKey::create(public_key_handle.release(),
|
| + WebKit::WebCryptoKeyTypePublic,
|
| + exportable,
|
| + algorithm,
|
| + usage));
|
| + WebKit::WebCryptoKey private_key(
|
| + WebKit::WebCryptoKey::create(private_key_handle.release(),
|
| + WebKit::WebCryptoKeyTypePrivate,
|
| + exportable,
|
| + algorithm,
|
| + usage));
|
| + result.completeWithKeyPair(public_key, private_key);
|
| + return;
|
| + }
|
| scoped_ptr<WebKit::WebCryptoKeyHandle> handle;
|
| WebKit::WebCryptoKeyType type;
|
| if (!GenerateKeyInternal(algorithm, &handle, &type)) {
|
| result.completeWithError();
|
| - } else {
|
| - WebKit::WebCryptoKey key(
|
| - WebKit::WebCryptoKey::create(handle.release(), type, exportable,
|
| - algorithm, usage));
|
| - result.completeWithKey(key);
|
| + return;
|
| }
|
| + WebKit::WebCryptoKey key(
|
| + WebKit::WebCryptoKey::create(handle.release(), type, exportable,
|
| + algorithm, usage));
|
| + result.completeWithKey(key);
|
| }
|
|
|
| void WebCryptoImpl::importKey(
|
|
|