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

Unified Diff: content/renderer/webcrypto/webcrypto_impl_nss.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
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl.cc ('k') | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webcrypto/webcrypto_impl_nss.cc
diff --git a/content/renderer/webcrypto/webcrypto_impl_nss.cc b/content/renderer/webcrypto/webcrypto_impl_nss.cc
index a20f72fb6bfd1bfe4336cb9a60deb8f15e3bd3f0..452d2a7c91dd34a52df66934b85ed8cd4e179627 100644
--- a/content/renderer/webcrypto/webcrypto_impl_nss.cc
+++ b/content/renderer/webcrypto/webcrypto_impl_nss.cc
@@ -263,8 +263,9 @@ bool WebCryptoImpl::DigestInternal(
bool WebCryptoImpl::GenerateKeyInternal(
const WebKit::WebCryptoAlgorithm& algorithm,
- scoped_ptr<WebKit::WebCryptoKeyHandle>* key,
- WebKit::WebCryptoKeyType* type) {
+ bool extractable,
+ WebKit::WebCryptoKeyUsageMask usage_mask,
+ WebKit::WebCryptoKey* key) {
CK_MECHANISM_TYPE mech = WebCryptoAlgorithmToGenMechanism(algorithm);
unsigned int keylen_bytes = 0;
@@ -317,9 +318,9 @@ bool WebCryptoImpl::GenerateKeyInternal(
return false;
}
- key->reset(new SymKeyHandle(pk11_key.Pass()));
- *type = key_type;
-
+ *key = WebKit::WebCryptoKey::create(
+ new SymKeyHandle(pk11_key.Pass()),
+ key_type, extractable, algorithm, usage_mask);
return true;
}
@@ -328,14 +329,21 @@ bool WebCryptoImpl::ImportKeyInternal(
WebKit::WebCryptoKeyFormat format,
const unsigned char* key_data,
unsigned key_data_size,
- const WebKit::WebCryptoAlgorithm& algorithm,
+ const WebKit::WebCryptoAlgorithm& algorithm_or_null,
+ bool extractable,
WebKit::WebCryptoKeyUsageMask usage_mask,
- scoped_ptr<WebKit::WebCryptoKeyHandle>* handle,
- WebKit::WebCryptoKeyType* type) {
+ 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;
+
+ WebKit::WebCryptoKeyType type;
switch (algorithm.id()) {
case WebKit::WebCryptoAlgorithmIdHmac:
case WebKit::WebCryptoAlgorithmIdAesCbc:
- *type = WebKit::WebCryptoKeyTypeSecret;
+ type = WebKit::WebCryptoKeyTypeSecret;
break;
// TODO(bryaneyler): Support more key types.
default:
@@ -402,9 +410,8 @@ bool WebCryptoImpl::ImportKeyInternal(
return false;
}
- scoped_ptr<SymKeyHandle> sym_key(new SymKeyHandle(pk11_sym_key.Pass()));
- *handle = sym_key.Pass();
-
+ *key = WebKit::WebCryptoKey::create(new SymKeyHandle(pk11_sym_key.Pass()),
+ type, extractable, algorithm, usage_mask);
return true;
}
« no previous file with comments | « content/renderer/webcrypto/webcrypto_impl.cc ('k') | content/renderer/webcrypto/webcrypto_impl_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698