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

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

Issue 19401003: Revert "WebCrypto: Add SHA-1 support to crypto.subtle.digest()." (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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.cpp ('k') | Source/web/WebArrayBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/SubtleCrypto.cpp
diff --git a/Source/modules/crypto/SubtleCrypto.cpp b/Source/modules/crypto/SubtleCrypto.cpp
index ee6d07461ae1dafbd7b285a9e016ef75dd738a36..cf30ddd50fa4b77964f14a94c0749893c7d31525 100644
--- a/Source/modules/crypto/SubtleCrypto.cpp
+++ b/Source/modules/crypto/SubtleCrypto.cpp
@@ -26,70 +26,18 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "config.h"
#include "modules/crypto/SubtleCrypto.h"
#include "core/dom/ExceptionCode.h"
#include "modules/crypto/CryptoOperation.h"
#include "modules/crypto/NormalizeAlgorithm.h"
-#include "public/platform/WebArrayBuffer.h" // FIXME: temporary
-#include "public/platform/WebCrypto.h"
#include "wtf/ArrayBuffer.h"
#include "wtf/ArrayBufferView.h"
-#include "wtf/SHA1.h" // FIXME: temporary
-
namespace WebCore {
-namespace {
-
-// FIXME: The following are temporary implementations of what *should* go on the
-// embedder's side. Since SHA1 is easily implemented, this serves as
-// a useful proof of concept to get layout tests up and running and
-// returning correct results, until the embedder's side is implemented.
-//------------------------------------------------------------------------------
-class DummyOperation : public WebKit::WebCryptoOperation {
-public:
- virtual void process(const unsigned char* bytes, size_t size) OVERRIDE
- {
- ASSERT_NOT_REACHED();
- }
- virtual void abort() OVERRIDE
- {
- delete this;
- }
- virtual void finish(WebKit::WebCryptoOperationResult* result) OVERRIDE
- {
- ASSERT_NOT_REACHED();
- }
-};
-
-class MockSha1Operation : public DummyOperation {
-public:
- virtual void process(const unsigned char* bytes, size_t size) OVERRIDE
- {
- m_sha1.addBytes(bytes, size);
- }
-
- virtual void finish(WebKit::WebCryptoOperationResult* result) OVERRIDE
- {
- Vector<uint8_t, 20> hash;
- m_sha1.computeHash(hash);
-
- WebKit::WebArrayBuffer buffer = WebKit::WebArrayBuffer::create(hash.size(), 1);
- memcpy(buffer.data(), hash.data(), hash.size());
-
- result->setArrayBuffer(buffer);
- delete this;
- }
-
-private:
- SHA1 m_sha1;
-};
-//------------------------------------------------------------------------------
-
-} // namespace
-
SubtleCrypto::SubtleCrypto()
{
ScriptWrappable::init(this);
@@ -100,7 +48,7 @@ PassRefPtr<CryptoOperation> SubtleCrypto::encrypt(const Dictionary& rawAlgorithm
WebKit::WebCryptoAlgorithm algorithm;
if (!normalizeAlgorithm(rawAlgorithm, Encrypt, algorithm, ec))
return 0;
- return CryptoOperation::create(algorithm, new DummyOperation);
+ return CryptoOperation::create(algorithm);
}
PassRefPtr<CryptoOperation> SubtleCrypto::decrypt(const Dictionary& rawAlgorithm, ExceptionCode& ec)
@@ -108,7 +56,7 @@ PassRefPtr<CryptoOperation> SubtleCrypto::decrypt(const Dictionary& rawAlgorithm
WebKit::WebCryptoAlgorithm algorithm;
if (!normalizeAlgorithm(rawAlgorithm, Decrypt, algorithm, ec))
return 0;
- return CryptoOperation::create(algorithm, new DummyOperation);
+ return CryptoOperation::create(algorithm);
}
PassRefPtr<CryptoOperation> SubtleCrypto::sign(const Dictionary& rawAlgorithm, ExceptionCode& ec)
@@ -116,7 +64,7 @@ PassRefPtr<CryptoOperation> SubtleCrypto::sign(const Dictionary& rawAlgorithm, E
WebKit::WebCryptoAlgorithm algorithm;
if (!normalizeAlgorithm(rawAlgorithm, Sign, algorithm, ec))
return 0;
- return CryptoOperation::create(algorithm, new DummyOperation);
+ return CryptoOperation::create(algorithm);
}
PassRefPtr<CryptoOperation> SubtleCrypto::verifySignature(const Dictionary& rawAlgorithm, ExceptionCode& ec)
@@ -124,7 +72,7 @@ PassRefPtr<CryptoOperation> SubtleCrypto::verifySignature(const Dictionary& rawA
WebKit::WebCryptoAlgorithm algorithm;
if (!normalizeAlgorithm(rawAlgorithm, Verify, algorithm, ec))
return 0;
- return CryptoOperation::create(algorithm, new DummyOperation);
+ return CryptoOperation::create(algorithm);
}
PassRefPtr<CryptoOperation> SubtleCrypto::digest(const Dictionary& rawAlgorithm, ExceptionCode& ec)
@@ -132,12 +80,7 @@ PassRefPtr<CryptoOperation> SubtleCrypto::digest(const Dictionary& rawAlgorithm,
WebKit::WebCryptoAlgorithm algorithm;
if (!normalizeAlgorithm(rawAlgorithm, Digest, algorithm, ec))
return 0;
-
- // FIXME: Create the WebCryptoImplementation by calling out to
- // Platform::crypto() instead.
- WebKit::WebCryptoOperation* operationImpl = algorithm.id() == WebKit::WebCryptoAlgorithmIdSha1 ? new MockSha1Operation : new DummyOperation;
-
- return CryptoOperation::create(algorithm, operationImpl);
+ return CryptoOperation::create(algorithm);
}
} // namespace WebCore
« no previous file with comments | « Source/modules/crypto/NormalizeAlgorithm.cpp ('k') | Source/web/WebArrayBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698