Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Unified Diff: content/renderer/webcrypto/webcrypto_impl_openssl.cc

Issue 50173002: [webcrypto] Refactor to allow for unspecified "algorithm" to importKey(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address sleevi comments and make NullKey() work in debug mode Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/webcrypto/webcrypto_impl_openssl.cc
diff --git a/content/renderer/webcrypto/webcrypto_impl_openssl.cc b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
index 5881b1bba7a7ef5c333e89468ec9aea742b9f4d0..83ae45c20e400460fd4a4dc12d6c581d37b5f6c9 100644
--- a/content/renderer/webcrypto/webcrypto_impl_openssl.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_openssl.cc
@@ -248,8 +248,9 @@ bool WebCryptoImpl::DigestInternal(const WebKit::WebCryptoAlgorithm& algorithm,
bool WebCryptoImpl::GenerateKeyInternal(
const WebKit::WebCryptoAlgorithm& algorithm,
- scoped_ptr<WebKit::WebCryptoKeyHandle>* key,
- WebKit::WebCryptoKeyType* type) {
+ bool extractable,
+ WebKit::WebCryptoKeyUsageMask usage_mask,
+ WebKit::WebCryptoKey* key) {
unsigned keylen_bytes = 0;
WebKit::WebCryptoKeyType key_type;
@@ -291,8 +292,9 @@ bool WebCryptoImpl::GenerateKeyInternal(
return false;
}
- key->reset(new SymKeyHandle(&random_bytes[0], random_bytes.size()));
- *type = key_type;
+ *key = WebKit::WebCryptoKey::create(
+ new SymKeyHandle(&random_bytes[0], random_bytes.size()),
+ key_type, extractable, algorithm, usage_mask);
return true;
}
@@ -301,10 +303,15 @@ bool WebCryptoImpl::ImportKeyInternal(
WebKit::WebCryptoKeyFormat format,
const unsigned char* key_data,
unsigned key_data_size,
- const WebKit::WebCryptoAlgorithm& algorithm,
- WebKit::WebCryptoKeyUsageMask /*usage_mask*/,
- scoped_ptr<WebKit::WebCryptoKeyHandle>* handle,
- WebKit::WebCryptoKeyType* type) {
+ const WebKit::WebCryptoAlgorithm& algorithm_or_null,
+ bool extractable,
+ WebKit::WebCryptoKeyUsageMask usage_mask,
+ WebKit::WebCryptoKey* key) {
+ // TODO(eroman): Currently expects algorithm to always be specified, as it is
+ // required for raw format.
+ if (algorithm_or_null.isNull())
+ return false;
+ const WebKit::WebCryptoAlgorithm& algorithm = algorithm_or_null;
// TODO(padolph): Support all relevant alg types and then remove this gate.
if (algorithm.id() != WebKit::WebCryptoAlgorithmIdHmac &&
@@ -321,7 +328,7 @@ bool WebCryptoImpl::ImportKeyInternal(
// they differ? (jwk, probably)
// Symmetric keys are always type secret
- *type = WebKit::WebCryptoKeyTypeSecret;
+ WebKit::WebCryptoKeyType type = WebKit::WebCryptoKeyTypeSecret;
const unsigned char* raw_key_data;
unsigned raw_key_data_size;
@@ -344,7 +351,9 @@ bool WebCryptoImpl::ImportKeyInternal(
return false;
}
- handle->reset(new SymKeyHandle(raw_key_data, raw_key_data_size));
+ *key = WebKit::WebCryptoKey::create(
+ new SymKeyHandle(raw_key_data, raw_key_data_size),
+ type, extractable, algorithm, usage_mask);
return true;
}
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl_nss.cc ('k') | content/renderer/webcrypto/webcrypto_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698