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

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

Issue 18475002: WebCrypto: Add framework for AlgorithmIdentifier normalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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/SubtleCrypto.cpp
diff --git a/Source/modules/crypto/SubtleCrypto.cpp b/Source/modules/crypto/SubtleCrypto.cpp
index 509d56585a70a4df25300660b6c51cdf48e25cf9..c9c56f1d931c04777c4edba139fd0f84c6cff660 100644
--- a/Source/modules/crypto/SubtleCrypto.cpp
+++ b/Source/modules/crypto/SubtleCrypto.cpp
@@ -31,6 +31,9 @@
#include "modules/crypto/SubtleCrypto.h"
#include "core/dom/ExceptionCode.h"
+#include "modules/crypto/CryptoOperation.h"
+#include "modules/crypto/NormalizeAlgorithm.h"
+#include "wtf/ArrayBuffer.h"
#include "wtf/ArrayBufferView.h"
namespace WebCore {
@@ -40,4 +43,44 @@ SubtleCrypto::SubtleCrypto()
ScriptWrappable::init(this);
}
+PassRefPtr<CryptoOperation> SubtleCrypto::encrypt(const Dictionary& rawAlgorithm, ExceptionCode& ec)
+{
+ WebKit::WebCryptoAlgorithm algorithm;
+ if (!normalizeAlgorithm(rawAlgorithm, Encrypt, algorithm, ec))
+ return 0;
+ return CryptoOperation::create(algorithm);
+}
+
+PassRefPtr<CryptoOperation> SubtleCrypto::decrypt(const Dictionary& rawAlgorithm, ExceptionCode& ec)
+{
+ WebKit::WebCryptoAlgorithm algorithm;
+ if (!normalizeAlgorithm(rawAlgorithm, Decrypt, algorithm, ec))
+ return 0;
+ return CryptoOperation::create(algorithm);
+}
+
+PassRefPtr<CryptoOperation> SubtleCrypto::sign(const Dictionary& rawAlgorithm, ExceptionCode& ec)
+{
+ WebKit::WebCryptoAlgorithm algorithm;
+ if (!normalizeAlgorithm(rawAlgorithm, Sign, algorithm, ec))
+ return 0;
+ return CryptoOperation::create(algorithm);
}
+
+PassRefPtr<CryptoOperation> SubtleCrypto::verify(const Dictionary& rawAlgorithm, ExceptionCode& ec)
+{
+ WebKit::WebCryptoAlgorithm algorithm;
+ if (!normalizeAlgorithm(rawAlgorithm, Verify, algorithm, ec))
+ return 0;
+ return CryptoOperation::create(algorithm);
+}
+
+PassRefPtr<CryptoOperation> SubtleCrypto::digest(const Dictionary& rawAlgorithm, ExceptionCode& ec)
+{
+ WebKit::WebCryptoAlgorithm algorithm;
+ if (!normalizeAlgorithm(rawAlgorithm, Digest, algorithm, ec))
+ return 0;
+ return CryptoOperation::create(algorithm);
+}
+
+} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698