summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/child/webcrypto/webcrypto_impl.cc41
-rw-r--r--content/child/webcrypto/webcrypto_impl.h17
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,