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

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

Issue 299843014: [webcrypto] Enable wrap/unwrap for SPKI and PKCS8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and address sleevi comments Created 6 years, 7 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 | « no previous file | content/child/webcrypto/shared_crypto_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/shared_crypto.cc
diff --git a/content/child/webcrypto/shared_crypto.cc b/content/child/webcrypto/shared_crypto.cc
index 8f4b05af70a6868e98521a370c5f5a97073dc78f..b4d5931327a31de64f6ec3a9dd5ab5fa2d96823b 100644
--- a/content/child/webcrypto/shared_crypto.cc
+++ b/content/child/webcrypto/shared_crypto.cc
@@ -865,26 +865,15 @@ Status WrapKey(blink::WebCryptoKeyFormat format,
if (wrapping_algorithm.id() != wrapping_key.algorithm().id())
return Status::ErrorUnexpected();
- switch (format) {
- case blink::WebCryptoKeyFormatRaw:
- if (wrapping_algorithm.id() == blink::WebCryptoAlgorithmIdAesKw) {
- // AES-KW is a special case, due to NSS's implementation only
- // supporting C_Wrap/C_Unwrap with AES-KW
- return WrapKeyRaw(
- key_to_wrap, wrapping_key, wrapping_algorithm, buffer);
- }
- return WrapKeyExportAndEncrypt(
- format, key_to_wrap, wrapping_key, wrapping_algorithm, buffer);
- case blink::WebCryptoKeyFormatJwk:
- return WrapKeyExportAndEncrypt(
- format, key_to_wrap, wrapping_key, wrapping_algorithm, buffer);
- case blink::WebCryptoKeyFormatSpki:
- case blink::WebCryptoKeyFormatPkcs8:
- return Status::ErrorUnsupported(); // TODO(padolph)
- default:
- NOTREACHED();
- return Status::ErrorUnsupported();
+ if (format == blink::WebCryptoKeyFormatRaw &&
+ wrapping_algorithm.id() == blink::WebCryptoAlgorithmIdAesKw) {
+ // AES-KW is a special case, due to NSS's implementation only
+ // supporting C_Wrap/C_Unwrap with AES-KW
+ return WrapKeyRaw(key_to_wrap, wrapping_key, wrapping_algorithm, buffer);
}
+
+ return WrapKeyExportAndEncrypt(
+ format, key_to_wrap, wrapping_key, wrapping_algorithm, buffer);
}
Status UnwrapKey(blink::WebCryptoKeyFormat format,
@@ -908,43 +897,27 @@ Status UnwrapKey(blink::WebCryptoKeyFormat format,
if (status.IsError())
return status;
- switch (format) {
- case blink::WebCryptoKeyFormatRaw:
- if (wrapping_algorithm.id() == blink::WebCryptoAlgorithmIdAesKw) {
- // AES-KW is a special case, due to NSS's implementation only
- // supporting C_Wrap/C_Unwrap with AES-KW
- return UnwrapKeyRaw(wrapped_key_data,
- wrapping_key,
- wrapping_algorithm,
- algorithm,
- extractable,
- usage_mask,
- key);
- }
- return UnwrapKeyDecryptAndImport(format,
- wrapped_key_data,
- wrapping_key,
- wrapping_algorithm,
- algorithm,
- extractable,
- usage_mask,
- key);
- case blink::WebCryptoKeyFormatJwk:
- return UnwrapKeyDecryptAndImport(format,
- wrapped_key_data,
- wrapping_key,
- wrapping_algorithm,
- algorithm,
- extractable,
- usage_mask,
- key);
- case blink::WebCryptoKeyFormatSpki:
- case blink::WebCryptoKeyFormatPkcs8:
- return Status::ErrorUnsupported(); // TODO(padolph)
- default:
- NOTREACHED();
- return Status::ErrorUnsupported();
+ if (format == blink::WebCryptoKeyFormatRaw &&
+ wrapping_algorithm.id() == blink::WebCryptoAlgorithmIdAesKw) {
+ // AES-KW is a special case, due to NSS's implementation only
+ // supporting C_Wrap/C_Unwrap with AES-KW
+ return UnwrapKeyRaw(wrapped_key_data,
+ wrapping_key,
+ wrapping_algorithm,
+ algorithm,
+ extractable,
+ usage_mask,
+ key);
}
+
+ return UnwrapKeyDecryptAndImport(format,
+ wrapped_key_data,
+ wrapping_key,
+ wrapping_algorithm,
+ algorithm,
+ extractable,
+ usage_mask,
+ key);
}
// Note that this function is called from the target Blink thread.
« no previous file with comments | « no previous file | content/child/webcrypto/shared_crypto_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698