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

Unified Diff: content/child/webcrypto/shared_crypto.cc

Issue 197223007: [webcrypto] Remove support for null import algorithms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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/child/webcrypto/shared_crypto.cc
diff --git a/content/child/webcrypto/shared_crypto.cc b/content/child/webcrypto/shared_crypto.cc
index 580754ae47966343874aee1766ea68b8d2672d52..76740f4cef3ce9a4e7b529c14ef53e24cb101b98 100644
--- a/content/child/webcrypto/shared_crypto.cc
+++ b/content/child/webcrypto/shared_crypto.cc
@@ -210,14 +210,11 @@ Status VerifyRsaSsaPkcs1v1_5(const blink::WebCryptoAlgorithm& algorithm,
}
Status ImportKeyRaw(const CryptoData& key_data,
- const blink::WebCryptoAlgorithm& algorithm_or_null,
+ const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
blink::WebCryptoKey* key) {
- if (algorithm_or_null.isNull())
- return Status::ErrorMissingAlgorithmImportRawKey();
-
- switch (algorithm_or_null.id()) {
+ switch (algorithm.id()) {
case blink::WebCryptoAlgorithmIdAesCtr:
case blink::WebCryptoAlgorithmIdAesCbc:
case blink::WebCryptoAlgorithmIdAesGcm:
@@ -227,7 +224,7 @@ Status ImportKeyRaw(const CryptoData& key_data,
// Fallthrough intentional!
case blink::WebCryptoAlgorithmIdHmac:
return platform::ImportKeyRaw(
- algorithm_or_null, key_data, extractable, usage_mask, key);
+ algorithm, key_data, extractable, usage_mask, key);
default:
return Status::ErrorUnsupported();
}
@@ -387,23 +384,23 @@ Status GenerateKeyPair(const blink::WebCryptoAlgorithm& algorithm,
Status ImportKey(blink::WebCryptoKeyFormat format,
const CryptoData& key_data,
- const blink::WebCryptoAlgorithm& algorithm_or_null,
+ const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
blink::WebCryptoKey* key) {
switch (format) {
case blink::WebCryptoKeyFormatRaw:
return ImportKeyRaw(
- key_data, algorithm_or_null, extractable, usage_mask, key);
+ key_data, algorithm, extractable, usage_mask, key);
case blink::WebCryptoKeyFormatSpki:
return platform::ImportKeySpki(
- algorithm_or_null, key_data, extractable, usage_mask, key);
+ algorithm, key_data, extractable, usage_mask, key);
case blink::WebCryptoKeyFormatPkcs8:
return platform::ImportKeyPkcs8(
- algorithm_or_null, key_data, extractable, usage_mask, key);
+ algorithm, key_data, extractable, usage_mask, key);
case blink::WebCryptoKeyFormatJwk:
return ImportKeyJwk(
- key_data, algorithm_or_null, extractable, usage_mask, key);
+ key_data, algorithm, extractable, usage_mask, key);
default:
return Status::ErrorUnsupported();
}
@@ -527,7 +524,7 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
const CryptoData& wrapped_key_data,
const blink::WebCryptoKey& wrapping_key,
const blink::WebCryptoAlgorithm& wrapping_algorithm,
- const blink::WebCryptoAlgorithm& algorithm_or_null,
+ const blink::WebCryptoAlgorithm& algorithm,
bool extractable,
blink::WebCryptoKeyUsageMask usage_mask,
blink::WebCryptoKey* key) {
@@ -540,10 +537,6 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
if (format != blink::WebCryptoKeyFormatRaw)
return Status::ErrorUnsupported();
- // Must provide an algorithm when unwrapping a raw key
- 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())
@@ -560,7 +553,7 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
return Status::ErrorInvalidAesKwDataLength();
return platform::UnwrapSymKeyAesKw(wrapped_key_data,
platform_wrapping_key,
- algorithm_or_null,
+ algorithm,
extractable,
usage_mask,
key);

Powered by Google App Engine
This is Rietveld 408576698