[WebCrypto] Add SHA-1
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2013 19:31:43 +0000 (19:31 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 31 Oct 2013 19:31:43 +0000 (19:31 +0000)
commit3c21c86a814b0ba77b8bf772d7a2b11d95717fc0
tree0ff1cbc711a4ce8f87628e43fe3387ffc3c2f4a8
parent4e7b6c5a3a2dd127b74b81328f3d61f1acdcc2ae
[WebCrypto] Add SHA-1
https://bugs.webkit.org/show_bug.cgi?id=123582

Reviewed by Anders Carlsson.

Source/WebCore:

Tests: security/crypto-subtle-arguments.html
       security/crypto-subtle-sha1.html

* WebCore.xcodeproj/project.pbxproj: Added new files.

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::createAlgorithmFromJSValue):
(WebCore::sequenceOfCryptoOperationDataFromJSValue):
(WebCore::JSSubtleCrypto::digest):
* crypto/SubtleCrypto.idl:
Added bindings for crypto.digest.

* crypto/algorithms: Added.
* crypto/algorithms/CryptoAlgorithmSHA1.cpp: Added.
* crypto/algorithms/CryptoAlgorithmSHA1.h: Added.
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms): Register SHA-1.

* crypto/mac/CryptoAlgorithmSHA1Mac.cpp: Added.
(WebCore::CryptoAlgorithmSHA1::digest): Performs the work synchronously, because
otherwise we'd have to copy the data first, which is crazy for something as simple
as hashing. We can change to a dispatch queue later if we find that it's actually
better to copy and do the work asynchronously.

LayoutTests:

* security/resources/common.js: Added from Blink.
(importTestKeys):
(asciiToArrayBuffer):
(printRejectedResult):
(printAcceptedResult):
(failAndFinishJSTest):

* security/crypto-subtle-arguments-expected.txt: Added.
* security/crypto-subtle-arguments.html: Added.
Added tests for how bindings treat crazy arguments. Heavily based on a test from Blink.

* security/crypto-subtle-sha1-expected.txt: Added.
* security/crypto-subtle-sha1.html: Added.
Test that SHA-1 works.

* TestExpectations: Skip these tests everywhere for now.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@158387 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/security/crypto-subtle-arguments-expected.txt [new file with mode: 0644]
LayoutTests/security/crypto-subtle-arguments.html [new file with mode: 0644]
LayoutTests/security/crypto-subtle-sha1-expected.txt [new file with mode: 0644]
LayoutTests/security/crypto-subtle-sha1.html [new file with mode: 0644]
LayoutTests/security/resources/common.js [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/crypto/SubtleCrypto.idl
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.cpp [new file with mode: 0644]
Source/WebCore/crypto/algorithms/CryptoAlgorithmSHA1.h [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
Source/WebCore/crypto/mac/CryptoAlgorithmSHA1Mac.cpp [new file with mode: 0644]