Index: Source/modules/crypto/NormalizeAlgorithm.cpp |
diff --git a/Source/modules/crypto/NormalizeAlgorithm.cpp b/Source/modules/crypto/NormalizeAlgorithm.cpp |
index 7e9657b72e5cb474b770164247aa630f9b058f8c..df83e7390d8c93f6127d0c7177ef8cc8fb5f1be8 100644 |
--- a/Source/modules/crypto/NormalizeAlgorithm.cpp |
+++ b/Source/modules/crypto/NormalizeAlgorithm.cpp |
@@ -189,30 +189,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, ExceptionState& es) |
+const AlgorithmInfo* algorithmInfo(const Dictionary& raw, ExceptionState& es) |
{ |
String algorithmName; |
if (!raw.get("name", algorithmName)) { |
es.throwDOMException(NotSupportedError); |
- return false; |
+ return 0; |
} |
if (!algorithmName.containsOnlyASCII()) { |
es.throwDOMException(SyntaxError); |
- return false; |
+ return 0; |
} |
const AlgorithmInfo* info = AlgorithmRegistry::lookupAlgorithmByName(algorithmName); |
if (!info) { |
es.throwDOMException(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, ExceptionState& es) |
+{ |
+ const AlgorithmInfo* info = algorithmInfo(raw, es); |
+ if (!info) |
+ return false; |
+ |
if (info->paramsForOperation[op] == UnsupportedOp) { |
es.throwDOMException(NotSupportedError); |
return false; |
@@ -230,4 +239,14 @@ bool normalizeAlgorithm(const Dictionary& raw, AlgorithmOperation op, WebKit::We |
return true; |
} |
+bool normalizeAlgorithmForImportKey(const Dictionary& raw, WebKit::WebCryptoAlgorithm& algorithm, ExceptionState& es) |
+{ |
+ const AlgorithmInfo* info = algorithmInfo(raw, es); |
+ if (!info) |
+ return false; |
+ |
+ algorithm = WebKit::WebCryptoAlgorithm(info->algorithmId, info->algorithmName, nullptr); |
+ return true; |
+} |
+ |
} // namespace WebCore |