| 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
|
|
|