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

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

Issue 794873002: Refactor: Remove switch statements on key format from algorithm_dispatch.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/child/webcrypto/algorithm_implementation.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/webcrypto/algorithm_implementation.cc
diff --git a/content/child/webcrypto/algorithm_implementation.cc b/content/child/webcrypto/algorithm_implementation.cc
index 6b9f7f9fc951779c63f1996f573d33774f0c01fe..3a62134f2df6aa6aabf441295481830129534ec5 100644
--- a/content/child/webcrypto/algorithm_implementation.cc
+++ b/content/child/webcrypto/algorithm_implementation.cc
@@ -74,6 +74,27 @@ Status AlgorithmImplementation::VerifyKeyUsagesBeforeImportKey(
return Status::ErrorUnsupportedImportKeyFormat();
}
+Status AlgorithmImplementation::ImportKey(
+ blink::WebCryptoKeyFormat format,
+ const CryptoData& key_data,
+ const blink::WebCryptoAlgorithm& algorithm,
+ bool extractable,
+ blink::WebCryptoKeyUsageMask usages,
+ blink::WebCryptoKey* key) const {
+ switch (format) {
+ case blink::WebCryptoKeyFormatRaw:
+ return ImportKeyRaw(key_data, algorithm, extractable, usages, key);
+ case blink::WebCryptoKeyFormatSpki:
+ return ImportKeySpki(key_data, algorithm, extractable, usages, key);
+ case blink::WebCryptoKeyFormatPkcs8:
+ return ImportKeyPkcs8(key_data, algorithm, extractable, usages, key);
+ case blink::WebCryptoKeyFormatJwk:
+ return ImportKeyJwk(key_data, algorithm, extractable, usages, key);
+ default:
+ return Status::ErrorUnsupported();
+ }
+}
+
Status AlgorithmImplementation::ImportKeyRaw(
const CryptoData& key_data,
const blink::WebCryptoAlgorithm& algorithm,
@@ -110,6 +131,23 @@ Status AlgorithmImplementation::ImportKeyJwk(
return Status::ErrorUnsupportedImportKeyFormat();
}
+Status AlgorithmImplementation::ExportKey(blink::WebCryptoKeyFormat format,
+ const blink::WebCryptoKey& key,
+ std::vector<uint8_t>* buffer) const {
+ switch (format) {
+ case blink::WebCryptoKeyFormatRaw:
+ return ExportKeyRaw(key, buffer);
+ case blink::WebCryptoKeyFormatSpki:
+ return ExportKeySpki(key, buffer);
+ case blink::WebCryptoKeyFormatPkcs8:
+ return ExportKeyPkcs8(key, buffer);
+ case blink::WebCryptoKeyFormatJwk:
+ return ExportKeyJwk(key, buffer);
+ default:
+ return Status::ErrorUnsupported();
+ }
+}
+
Status AlgorithmImplementation::ExportKeyRaw(
const blink::WebCryptoKey& key,
std::vector<uint8_t>* buffer) const {
« no previous file with comments | « content/child/webcrypto/algorithm_implementation.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698