Index: Source/modules/crypto/NormalizeAlgorithm.cpp |
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp |
index fa4c3e1bb76642a8867c88b95201507abfb5f6a3..aeeb9fc8f7f57dd83638a8d9f096d2e6d2700855 100644 |
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp |
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp |
@@ -188,30 +188,39 @@ 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) |
+const AlgorithmInfo* algorithmInfo(const Dictionary& raw, ExceptionCode& ec) |
{ |
String algorithmName; |
if (!raw.get("name", algorithmName)) { |
ec = NotSupportedError; |
- return false; |
+ return 0; |
} |
if (!algorithmName.containsOnlyASCII()) { |
ec = SyntaxError; |
- return false; |
+ return 0; |
} |
const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorithmName); |
if (!info) { |
ec = NotSupportedError; |
- return false; |
+ return 0; |
} |
+ return info; |
+} |
+ |
+} // 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 = algorithmInfo(raw, ec); |
+ if (!info) |
+ 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 = algorithmInfo(raw, ec); |
+ if (!info) |
+ return false; |
+ |
+ algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmName, nullptr); |
+ return true; |
+} |
+ |
} // namespace WebCore |