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 |