Implement PBKDF2 in WebCrypto
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2017 22:24:26 +0000 (22:24 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Mar 2017 22:24:26 +0000 (22:24 +0000)
commit8c070090ec333325ba9860e82e0797d8c83458b8
treec9c7e5ac2435fa9c5de4ad64efedf0f6feb9f7ea
parentb6aa6f1d40f773069e61c844c34d7f5e27b271e1
Implement PBKDF2 in WebCrypto
https://bugs.webkit.org/show_bug.cgi?id=143458
<rdar://problem/27311703>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/derive_bits_keys/pbkdf2.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/derive_bits_keys/test_pbkdf2-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 PBKDF2 according to the spec:
https://www.w3.org/TR/WebCryptoAPI/#pbkdf2. Supported
operations include deriveKey, deriveBits, importKey and
getKeyLength.

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

* CMakeLists.txt:
* DerivedSources.make:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSCryptoKeyCustom.cpp:
(WebCore::JSCryptoKey::algorithm):
Added RawKeyAlgorithm.
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
A bit of reordering.
* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
Faked implementation.
* crypto/CryptoAlgorithmParameters.h:
* crypto/CryptoKey.h:
* crypto/algorithms/CryptoAlgorithmPBKDF2.cpp: Added.
(WebCore::CryptoAlgorithmPBKDF2::create):
(WebCore::CryptoAlgorithmPBKDF2::identifier):
(WebCore::CryptoAlgorithmPBKDF2::deriveBits):
(WebCore::CryptoAlgorithmPBKDF2::importKey):
(WebCore::CryptoAlgorithmPBKDF2::getKeyLength):
* crypto/algorithms/CryptoAlgorithmPBKDF2.h: Added.
* crypto/gnutls/CryptoAlgorithmPBKDF2GnuTLS.cpp: Added.
(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
* crypto/keys/CryptoKeyRaw.cpp: Added.
(WebCore::CryptoKeyRaw::CryptoKeyRaw):
(WebCore::CryptoKeyRaw::buildAlgorithm):
(WebCore::CryptoKeyRaw::exportData):
* crypto/keys/CryptoKeyRaw.h: Added.
(WebCore::RawKeyAlgorithm::RawKeyAlgorithm):
The CryptoKey class for PBKDF2 and later on HKDF.
* crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp: Added.
(WebCore::commonCryptoHMACAlgorithm):
(WebCore::CryptoAlgorithmPBKDF2::platformDeriveBits):
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
* crypto/parameters/CryptoAlgorithmPbkdf2Params.h: Added.
* crypto/parameters/Pbkdf2Params.idl: Added.

LayoutTests:

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213671 268f45cc-cd09-0410-ab3c-d52691b4dbfc
50 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/crypto/subtle/derive-key-malformed-parameters-expected.txt
LayoutTests/crypto/subtle/derive-key-malformed-parameters.html
LayoutTests/crypto/subtle/ecdh-import-key-derive-pbkdf2-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/ecdh-import-key-derive-pbkdf2-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-derive-bits-malformed-parametrs-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-derive-bits-malformed-parametrs.html [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-derive-bits-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-derive-bits.html [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-derive-hmac-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-derive-hmac-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/pbkdf2-import-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key-derive-bits-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key-derive-bits.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key-derive-hmac-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key-derive-hmac-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/pbkdf2-import-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/pbkdf2-import-key-derive-bits.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/pbkdf2-import-key-derive-hmac-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/pbkdf2-import-key.js [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/pbkdf2.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_pbkdf2-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/JSCryptoKeyCustom.cpp
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/SerializedScriptValue.cpp
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/CryptoKey.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.cpp [new file with mode: 0644]
Source/WebCore/crypto/algorithms/CryptoAlgorithmPBKDF2.h [new file with mode: 0644]
Source/WebCore/crypto/gnutls/CryptoAlgorithmPBKDF2GnuTLS.cpp [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyRaw.cpp [new file with mode: 0644]
Source/WebCore/crypto/keys/CryptoKeyRaw.h [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmPBKDF2Mac.cpp [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
Source/WebCore/crypto/parameters/CryptoAlgorithmPbkdf2Params.h [new file with mode: 0644]
Source/WebCore/crypto/parameters/Pbkdf2Params.idl [new file with mode: 0644]