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

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: Rebase and rename Interface --> Private 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
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.h ('k') | Source/modules/crypto/SubtleCrypto.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.h ('k') | Source/modules/crypto/SubtleCrypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698