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

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

Issue 786363002: Refactor: Extract common code for generating asymmetric keys to a helper. (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/webcrypto_util.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/webcrypto_util.cc
diff --git a/content/child/webcrypto/webcrypto_util.cc b/content/child/webcrypto/webcrypto_util.cc
index 6dad83fcae7dae6c9cb0bd1ecd7b50139d56c670..d4995a93b0d37da3656fc501642491d19b508e55 100644
--- a/content/child/webcrypto/webcrypto_util.cc
+++ b/content/child/webcrypto/webcrypto_util.cc
@@ -262,6 +262,29 @@ Status GetRsaKeyGenParameters(
return Status::Success();
}
+Status GetUsagesForGenerateAsymmetricKey(
+ blink::WebCryptoKeyUsageMask combined_usages,
+ blink::WebCryptoKeyUsageMask all_public_usages,
+ blink::WebCryptoKeyUsageMask all_private_usages,
+ blink::WebCryptoKeyUsageMask* public_usages,
+ blink::WebCryptoKeyUsageMask* private_usages) {
+ *public_usages = combined_usages & all_public_usages;
+ *private_usages = combined_usages & all_private_usages;
+
+ Status status = CheckKeyCreationUsages(all_public_usages, *public_usages);
+ if (status.IsError())
+ return status;
+
+ status = CheckKeyCreationUsages(all_private_usages, *private_usages);
+ if (status.IsError())
+ return status;
+
+ if (private_usages == 0)
+ return Status::ErrorCreateKeyEmptyUsages();
+
+ return Status::Success();
+}
+
} // namespace webcrypto
} // namespace content
« no previous file with comments | « content/child/webcrypto/webcrypto_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698