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

Unified Diff: Source/modules/crypto/NormalizeAlgorithm.cpp

Issue 19885002: WebCrypto: Add interfaces for importKey(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move test stuff into MockWebCrypto Created 7 years, 5 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: Source/modules/crypto/NormalizeAlgorithm.cpp
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp
index fa4c3e1bb76642a8867c88b95201507abfb5f6a3..e31b84f16b1c62a4870926ceb5f16f024203ac74 100644
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp
@@ -188,12 +188,7 @@ PassOwnPtr<WebKit::WebCryptoAlgorithmParams> parseAlgorithmParams(const Dictiona
return nullptr;
}
-} // namespace
-
-// FIXME: Throw the correct exception types!
-// This implementation corresponds with:
-// http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules
-bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::WebCryptoAlgorithm& algorithm, ExceptionCode& ec)
+bool getAlgorithmInfo(const Dictionary& raw, const AlgorithmInfo*& info, ExceptionCode& ec)
abarth-chromium 2013/07/23 06:22:07 We generally try to avoid using "get" as a verb in
eroman 2013/07/23 23:29:02 Done.
{
String algorithmName;
if (!raw.get("name", algorithmName)) {
@@ -206,12 +201,26 @@ bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We
return false;
}
- const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorithmName);
+ info = AlgorithmRegistry::lookupAlgorithmByName(algorithmName);
if (!info) {
ec = NotSupportedError;
return false;
}
+ return true;
+}
+
+} // namespace
+
+// FIXME: Throw the correct exception types!
+// This implementation corresponds with:
+// http://www.w3.org/TR/WebCryptoAPI/#algorithm-normalizing-rules
+bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::WebCryptoAlgorithm& algorithm, ExceptionCode& ec)
+{
+ const AlgorithmInfo* info;
abarth-chromium 2013/07/23 06:22:07 Please initialize scalars.
eroman 2013/07/23 23:29:02 Done.
+ if (!getAlgorithmInfo(raw, info, ec))
+ return false;
+
if (info->paramsForOperation[op] == UnsupportedOp) {
ec = NotSupportedError;
return false;
@@ -229,4 +238,14 @@ bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We
return true;
}
+bool normalizeAlgorithmForImportKey(const Dictionary& raw, WebKit::WebCryptoAlgorithm& algorithm, ExceptionCode& ec)
+{
+ const AlgorithmInfo* info;
+ if (!getAlgorithmInfo(raw, info, ec))
+ return false;
+
+ algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmName, nullptr);
+ return true;
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698