[WebCrypto] Support HKDF
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Apr 2017 00:17:09 +0000 (00:17 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 15 Apr 2017 00:17:09 +0000 (00:17 +0000)
commit951f2fa57cf33cf0ccca8aa4adfe3173521f7967
tree29c7fe0a17b6b7fe00338190c1b26acf32cc6091
parentd259e3515d2f68bca9f608fa3e96abc8febbb5ed
[WebCrypto] Support HKDF
https://bugs.webkit.org/show_bug.cgi?id=170636
<rdar://problem/23539827>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/derive_bits_keys/test_hkdf-expected.txt:
* web-platform-tests/WebCryptoAPI/import_export/symmetric_importKey.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/import_export/test_symmetric_importKey-expected.txt:

Source/WebCore:

This patch implements HKDF according to the spec: https://www.w3.org/TR/WebCryptoAPI/#hkdf.
Supported operations include deriveKey, deriveBits, importKey and getKeyLength.

Tests: crypto/subtle/ecdh-import-key-derive-hkdf-key.html
       crypto/subtle/hkdf-derive-bits-malformed-parametrs.html
       crypto/subtle/hkdf-import-key-derive-bits.html
       crypto/subtle/hkdf-import-key-derive-hmac-key.html
       crypto/subtle/hkdf-import-key-malformed-parameters.html
       crypto/subtle/hkdf-import-key.html
       crypto/workers/subtle/hkdf-import-key-derive-bits.html
       crypto/workers/subtle/hkdf-import-key-derive-hmac-key.html
       crypto/workers/subtle/hkdf-import-key.html

* CMakeLists.txt:
* DerivedSources.make:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCryptoAlgorithmDictionary.cpp:
(WebCore::JSCryptoAlgorithmDictionary::createParametersForEncrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDecrypt):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForSign):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForVerify):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDigest):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForGenerateKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForDeriveBits):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForImportKey):
(WebCore::JSCryptoAlgorithmDictionary::createParametersForExportKey):
Rename HKDF_CTR to HKDF.
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
(WebCore::CloneDeserializer::read):
Rename HKDF_CTR to HKDF.
* crypto/CommonCryptoUtilities.h:
* crypto/CryptoAlgorithmIdentifier.h:
* crypto/CryptoAlgorithmParameters.h:
* crypto/algorithms/CryptoAlgorithmHKDF.cpp: Added.
(WebCore::CryptoAlgorithmHKDF::create):
(WebCore::CryptoAlgorithmHKDF::identifier):
(WebCore::CryptoAlgorithmHKDF::deriveBits):
(WebCore::CryptoAlgorithmHKDF::importKey):
(WebCore::CryptoAlgorithmHKDF::getKeyLength):
* crypto/algorithms/CryptoAlgorithmHKDF.h: Added.
* crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp: Added.
(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
* crypto/mac/CryptoAlgorithmHKDFMac.cpp: Added.
(WebCore::CryptoAlgorithmHKDF::platformDeriveBits):
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
* crypto/parameters/CryptoAlgorithmHkdfParams.h: Added.
* crypto/parameters/HkdfParams.idl: Added.

LayoutTests:

* TestExpectations:
* crypto/subtle/ecdh-import-key-derive-hkdf-key-expected.txt: Added.
* crypto/subtle/ecdh-import-key-derive-hkdf-key.html: Added.
* crypto/subtle/hkdf-derive-bits-malformed-parametrs-expected.txt: Added.
* crypto/subtle/hkdf-derive-bits-malformed-parametrs.html: Added.
* crypto/subtle/hkdf-import-key-derive-bits-expected.txt: Added.
* crypto/subtle/hkdf-import-key-derive-bits.html: Added.
* crypto/subtle/hkdf-import-key-derive-hmac-key-expected.txt: Added.
* crypto/subtle/hkdf-import-key-derive-hmac-key.html: Added.
* crypto/subtle/hkdf-import-key-expected.txt: Added.
* crypto/subtle/hkdf-import-key-malformed-parameters-expected.txt: Added.
* crypto/subtle/hkdf-import-key-malformed-parameters.html: Added.
* crypto/subtle/hkdf-import-key.html: Added.
* crypto/workers/subtle/hkdf-import-key-derive-bits-expected.txt: Added.
* crypto/workers/subtle/hkdf-import-key-derive-bits.html: Added.
* crypto/workers/subtle/hkdf-import-key-derive-hmac-key-expected.txt: Added.
* crypto/workers/subtle/hkdf-import-key-derive-hmac-key.html: Added.
* crypto/workers/subtle/hkdf-import-key-expected.txt: Added.
* crypto/workers/subtle/hkdf-import-key.html: Added.
* crypto/workers/subtle/resources/hkdf-import-key-derive-bits.js: Added.
* crypto/workers/subtle/resources/hkdf-import-key-derive-hmac-key.js: Added.
* crypto/workers/subtle/resources/hkdf-import-key.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215382 268f45cc-cd09-0410-ab3c-d52691b4dbfc
47 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/crypto/subtle/ecdh-import-key-derive-hkdf-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-import-key-derive-hkdf-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-derive-bits-malformed-parametrs-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-derive-bits-malformed-parametrs.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-derive-bits-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-derive-bits.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-derive-hmac-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-derive-hmac-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/hkdf-import-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key-derive-bits-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key-derive-bits.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key-derive-hmac-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key-derive-hmac-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/hkdf-import-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hkdf-import-key-derive-bits.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hkdf-import-key-derive-hmac-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/hkdf-import-key.js [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/hkdf.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_hkdf-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/symmetric_importKey.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_symmetric_importKey-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/JSCryptoAlgorithmDictionary.cpp
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/crypto/CommonCryptoUtilities.h
Source/WebCore/crypto/CryptoAlgorithmIdentifier.h
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.cpp [new file with mode: 0644]
Source/WebCore/crypto/algorithms/CryptoAlgorithmHKDF.h [new file with mode: 0644]
Source/WebCore/crypto/gcrypt/CryptoAlgorithmHKDFGCrypt.cpp [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmHKDFMac.cpp [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
Source/WebCore/crypto/parameters/CryptoAlgorithmHkdfParams.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/HkdfParams.idl [new file with mode: 0644]