[WebCrypto] Implement ECDH GenerateKey operation
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 02:56:58 +0000 (02:56 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Mar 2017 02:56:58 +0000 (02:56 +0000)
commit67fe21445a898aec714dac96319c89fc64afc6f4
tree3b0559a3f0d860e05dedf6d6047c3f636af034f5
parent89eafb2cd8923c2a63c72e7729c0143bb3079b0c
[WebCrypto] Implement ECDH GenerateKey operation
https://bugs.webkit.org/show_bug.cgi?id=169093
<rdar://problem/23789585>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/generateKey/failures_ECDH.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/successes_ECDH.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDH-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDH-expected.txt:

Source/WebCore:

This patch implements GenerateKey operation of ECDH according to:
https://www.w3.org/TR/WebCryptoAPI/#ecdh-operations.
Note: Sad that we are not able to support P-521 at this moment due
to lack of necessary support in the underlying crypto library.

Tests: crypto/subtle/ec-generate-key-malformed-parameters.html
       crypto/subtle/ecdh-generate-key-extractable.html
       crypto/subtle/ecdh-generate-key-p256.html
       crypto/subtle/ecdh-generate-key-p384.html
       crypto/subtle/ecdh-generate-key-single-usage.html
       crypto/workers/subtle/ec-generate-key.html

* CMakeLists.txt:
* DerivedSources.make:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCryptoKeyCustom.cpp:
(WebCore::JSCryptoKey::algorithm):
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::jsSubtleCryptoFunctionGenerateKeyPromise):
Add support for ECDH.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
Structured clonable will be added later on.
* crypto/CommonCryptoUtilities.h:
Add SPI for EC.
* crypto/CryptoAlgorithmParameters.h:
* crypto/CryptoKey.h:
* crypto/algorithms/CryptoAlgorithmECDH.cpp: Added.
(WebCore::CryptoAlgorithmECDH::create):
(WebCore::CryptoAlgorithmECDH::identifier):
(WebCore::CryptoAlgorithmECDH::generateKey):
* crypto/algorithms/CryptoAlgorithmECDH.h: Added.
* crypto/gnutls/CryptoKeyECGnuTLS.cpp: Added.
(WebCore::CryptoKeyEC::~CryptoKeyEC):
(WebCore::CryptoKeyEC::platformGeneratePair):
* crypto/keys/CryptoKeyEC.cpp: Added.
(WebCore::CryptoKeyEC::CryptoKeyEC):
(WebCore::CryptoKeyEC::generatePair):
(WebCore::CryptoKeyEC::buildAlgorithm):
(WebCore::CryptoKeyEC::exportData):
* crypto/keys/CryptoKeyEC.h: Added.
(WebCore::EcKeyAlgorithm::EcKeyAlgorithm):
(WebCore::EcKeyAlgorithm::namedCurve):
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
Add support for ECDH.
* crypto/mac/CryptoKeyECMac.cpp: Added.
(WebCore::CryptoKeyEC::~CryptoKeyEC):
(WebCore::CryptoKeyEC::platformGeneratePair):
* crypto/parameters/CryptoAlgorithmEcKeyParams.h: Added.
* crypto/parameters/EcKeyParams.idl: Added.

LayoutTests:

* crypto/subtle/ec-generate-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/ec-generate-key-malformed-parameters.html: Added.
* crypto/subtle/ecdh-generate-key-extractable-expected.txt: Added.
* crypto/subtle/ecdh-generate-key-extractable.html: Added.
* crypto/subtle/ecdh-generate-key-p256-expected.txt: Added.
* crypto/subtle/ecdh-generate-key-p256.html: Added.
* crypto/subtle/ecdh-generate-key-p384-expected.txt: Added.
* crypto/subtle/ecdh-generate-key-p384.html: Added.
* crypto/subtle/ecdh-generate-key-single-usage-expected.txt: Added.
* crypto/subtle/ecdh-generate-key-single-usage.html: Added.
* crypto/workers/subtle/ec-generate-key-expected.txt: Added.
* crypto/workers/subtle/ec-generate-key.html: Added.
* crypto/workers/subtle/resources/ec-generate-key.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213489 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/ec-generate-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ec-generate-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-extractable-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-extractable.html [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-p256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-p256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-p384-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-p384.html [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-single-usage-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-generate-key-single-usage.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/ec-generate-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/ec-generate-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/ec-generate-key.js [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_ECDH.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_ECDH.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDH-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDH-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformMac.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSCryptoKeyCustom.cpp
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/crypto/CommonCryptoUtilities.h
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/CryptoKey.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.cpp [new file with mode: 0644]
Source/WebCore/crypto/algorithms/CryptoAlgorithmECDH.h [new file with mode: 0644]
Source/WebCore/crypto/gnutls/CryptoKeyECGnuTLS.cpp [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyEC.cpp [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyEC.h [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
Source/WebCore/crypto/mac/CryptoKeyECMac.cpp [new file with mode: 0644]
Source/WebCore/crypto/parameters/CryptoAlgorithmEcKeyParams.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/EcKeyParams.idl [new file with mode: 0644]