diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-25 01:07:38 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-25 01:07:38 +0000 |
commit | baa9284fc574976cd16bf27bb913bb5db278442d (patch) | |
tree | d525eb6cb2cdf6d68105087bb4fbca9e44368284 /content/child/webcrypto | |
parent | f030c4dda19502c471f27ffbb56c0b6697e1d108 (diff) | |
download | chromium_src-baa9284fc574976cd16bf27bb913bb5db278442d.zip chromium_src-baa9284fc574976cd16bf27bb913bb5db278442d.tar.gz chromium_src-baa9284fc574976cd16bf27bb913bb5db278442d.tar.bz2 |
[webcrypto] Add wrap/unwrap forwarding methods to WebCryptoImpl.
The tests for this will have to be on the blink size.
BUG=245025
Review URL: https://codereview.chromium.org/206833003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259073 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/child/webcrypto')
-rw-r--r-- | content/child/webcrypto/webcrypto_impl.cc | 41 | ||||
-rw-r--r-- | content/child/webcrypto/webcrypto_impl.h | 17 |
2 files changed, 57 insertions, 1 deletions
diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc index d0c5196..076df0d 100644 --- a/content/child/webcrypto/webcrypto_impl.cc +++ b/content/child/webcrypto/webcrypto_impl.cc @@ -195,6 +195,47 @@ void WebCryptoImpl::verifySignature(const blink::WebCryptoAlgorithm& algorithm, result.completeWithBoolean(signature_match); } +void WebCryptoImpl::wrapKey(blink::WebCryptoKeyFormat format, + const blink::WebCryptoKey& key, + const blink::WebCryptoKey& wrapping_key, + const blink::WebCryptoAlgorithm& wrap_algorithm, + blink::WebCryptoResult result) { + blink::WebArrayBuffer buffer; + // TODO(eroman): Use the same parameter ordering. + Status status = webcrypto::WrapKey( + format, wrapping_key, key, wrap_algorithm, &buffer); + if (status.IsError()) + CompleteWithError(status, &result); + else + result.completeWithBuffer(buffer); +} + +void WebCryptoImpl::unwrapKey( + blink::WebCryptoKeyFormat format, + const unsigned char* wrapped_key, + unsigned wrapped_key_size, + const blink::WebCryptoKey& wrapping_key, + const blink::WebCryptoAlgorithm& unwrap_algorithm, + const blink::WebCryptoAlgorithm& unwrapped_key_algorithm, + bool extractable, + blink::WebCryptoKeyUsageMask usages, + blink::WebCryptoResult result) { + blink::WebCryptoKey key = blink::WebCryptoKey::createNull(); + Status status = + webcrypto::UnwrapKey(format, + webcrypto::CryptoData(wrapped_key, wrapped_key_size), + wrapping_key, + unwrap_algorithm, + unwrapped_key_algorithm, + extractable, + usages, + &key); + if (status.IsError()) + CompleteWithError(status, &result); + else + result.completeWithKey(key); +} + bool WebCryptoImpl::digestSynchronous( const blink::WebCryptoAlgorithmId algorithm_id, const unsigned char* data, diff --git a/content/child/webcrypto/webcrypto_impl.h b/content/child/webcrypto/webcrypto_impl.h index 9cc7c36..bdb3928 100644 --- a/content/child/webcrypto/webcrypto_impl.h +++ b/content/child/webcrypto/webcrypto_impl.h @@ -61,7 +61,22 @@ class WebCryptoImpl : public blink::WebCrypto { unsigned int signature_size, const unsigned char* data, unsigned int data_size, - blink::WebCryptoResult result); + blink::WebCryptoResult result); + virtual void wrapKey(blink::WebCryptoKeyFormat format, + const blink::WebCryptoKey& key, + const blink::WebCryptoKey& wrapping_key, + const blink::WebCryptoAlgorithm& wrap_algorithm, + blink::WebCryptoResult result); + virtual void unwrapKey( + blink::WebCryptoKeyFormat format, + const unsigned char* wrapped_key, + unsigned wrapped_key_size, + const blink::WebCryptoKey& wrapping_key, + const blink::WebCryptoAlgorithm& unwrap_algorithm, + const blink::WebCryptoAlgorithm& unwrapped_key_algorithm, + bool extractable, + blink::WebCryptoKeyUsageMask usages, + blink::WebCryptoResult result); // This method synchronously computes a digest for the given data, returning // |true| if successful and |false| otherwise. virtual bool digestSynchronous(const blink::WebCryptoAlgorithmId algorithm_id, |