| Index: content/child/webcrypto/shared_crypto.cc
|
| diff --git a/content/child/webcrypto/shared_crypto.cc b/content/child/webcrypto/shared_crypto.cc
|
| index cffdcc54dd9dc5290db18c08244ba8274e394d9b..e392b6362bc128d071b70094110eec6834b3772c 100644
|
| --- a/content/child/webcrypto/shared_crypto.cc
|
| +++ b/content/child/webcrypto/shared_crypto.cc
|
| @@ -497,20 +497,29 @@ Status WrapKey(blink::WebCryptoKeyFormat format,
|
| if (key_to_wrap.type() != blink::WebCryptoKeyTypeSecret)
|
| return Status::ErrorUnsupported();
|
|
|
| - platform::SymKey* platform_wrapping_key;
|
| - Status status = ToPlatformSymKey(wrapping_key, &platform_wrapping_key);
|
| - if (status.IsError())
|
| - return status;
|
| platform::SymKey* platform_key;
|
| - status = ToPlatformSymKey(key_to_wrap, &platform_key);
|
| + Status status = ToPlatformSymKey(key_to_wrap, &platform_key);
|
| if (status.IsError())
|
| return status;
|
|
|
| // TODO(padolph): Handle other wrapping algorithms
|
| switch (wrapping_algorithm.id()) {
|
| - case blink::WebCryptoAlgorithmIdAesKw:
|
| + case blink::WebCryptoAlgorithmIdAesKw: {
|
| + platform::SymKey* platform_wrapping_key;
|
| + status = ToPlatformSymKey(wrapping_key, &platform_wrapping_key);
|
| + if (status.IsError())
|
| + return status;
|
| return platform::WrapSymKeyAesKw(
|
| platform_wrapping_key, platform_key, buffer);
|
| + }
|
| + case blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5: {
|
| + platform::PublicKey* platform_wrapping_key;
|
| + status = ToPlatformPublicKey(wrapping_key, &platform_wrapping_key);
|
| + if (status.IsError())
|
| + return status;
|
| + return platform::WrapSymKeyRsaEs(
|
| + platform_wrapping_key, platform_key, buffer);
|
| + }
|
| default:
|
| return Status::ErrorUnsupported();
|
| }
|
| @@ -537,14 +546,13 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
|
| if (format == blink::WebCryptoKeyFormatRaw && algorithm_or_null.isNull())
|
| return Status::ErrorMissingAlgorithmUnwrapRawKey();
|
|
|
| - platform::SymKey* platform_wrapping_key;
|
| - Status status = ToPlatformSymKey(wrapping_key, &platform_wrapping_key);
|
| - if (status.IsError())
|
| - return status;
|
| -
|
| // TODO(padolph): Handle other wrapping algorithms
|
| switch (wrapping_algorithm.id()) {
|
| case blink::WebCryptoAlgorithmIdAesKw: {
|
| + platform::SymKey* platform_wrapping_key;
|
| + Status status = ToPlatformSymKey(wrapping_key, &platform_wrapping_key);
|
| + if (status.IsError())
|
| + return status;
|
| // AES-KW requires the wrapped key data size must be at least 24 bytes and
|
| // also a multiple of 8 bytes.
|
| if (wrapped_key_data.byte_length() < 24)
|
| @@ -558,6 +566,19 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
|
| usage_mask,
|
| key);
|
| }
|
| + case blink::WebCryptoAlgorithmIdRsaEsPkcs1v1_5: {
|
| + platform::PrivateKey* platform_wrapping_key;
|
| + Status status =
|
| + ToPlatformPrivateKey(wrapping_key, &platform_wrapping_key);
|
| + if (status.IsError())
|
| + return status;
|
| + return platform::UnwrapSymKeyRsaEs(wrapped_key_data,
|
| + platform_wrapping_key,
|
| + algorithm_or_null,
|
| + extractable,
|
| + usage_mask,
|
| + key);
|
| + }
|
| default:
|
| return Status::ErrorUnsupported();
|
| }
|
|
|