WebCrypto API support for AES-GCM
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2017 21:55:55 +0000 (21:55 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Mar 2017 21:55:55 +0000 (21:55 +0000)
commitcab27251ac85f59c7c034b66aace1a7bfef73dcb
treef9412f41f99733f3aaa292b373542000887fb10c
parent6368a3552da70822668fba72c17b4d418069d643
WebCrypto API support for AES-GCM
https://bugs.webkit.org/show_bug.cgi?id=157175
<rdar://problem/27311691>

Reviewed by Brent Fulgham.

LayoutTests/imported/w3c:

* web-platform-tests/WebCryptoAPI/encrypt_decrypt/aes_gcm.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/failures_AES-GCM.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/successes_AES-GCM.worker-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt:
* web-platform-tests/WebCryptoAPI/generateKey/test_successes_AES-GCM-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 adds support for AES-GCM. Operations of AES-GCM include: encrypt, decrypt, generateKey,
importKey, exportKey, wrapKey, and unwrapKey. https://www.w3.org/TR/WebCryptoAPI/#aes-gcm

Tests: crypto/subtle/aes-gcm-decrypt-malformed-parameters.html
       crypto/subtle/aes-gcm-encrypt-malformed-parameters.html
       crypto/subtle/aes-gcm-generate-export-key-jwk-length-128.html
       crypto/subtle/aes-gcm-generate-export-key-jwk-length-192.html
       crypto/subtle/aes-gcm-generate-export-key-jwk-length-256.html
       crypto/subtle/aes-gcm-generate-export-raw-key.html
       crypto/subtle/aes-gcm-generate-key-encrypt-decrypt.html
       crypto/subtle/aes-gcm-generate-key.html
       crypto/subtle/aes-gcm-import-jwk-key-length-128.html
       crypto/subtle/aes-gcm-import-jwk-key-length-192.html
       crypto/subtle/aes-gcm-import-jwk-key-length-256.html
       crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32.html
       crypto/subtle/aes-gcm-import-key-decrypt-additional-data.html
       crypto/subtle/aes-gcm-import-key-decrypt-tagLengths.html
       crypto/subtle/aes-gcm-import-key-decrypt.html
       crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32.html
       crypto/subtle/aes-gcm-import-key-encrypt-additional-data.html
       crypto/subtle/aes-gcm-import-key-encrypt-tagLengths.html
       crypto/subtle/aes-gcm-import-key-encrypt.html
       crypto/subtle/aes-gcm-import-key-unwrap-jwk-key.html
       crypto/subtle/aes-gcm-import-key-unwrap-raw-key.html
       crypto/subtle/aes-gcm-import-key-wrap-jwk-key.html
       crypto/subtle/aes-gcm-import-key-wrap-raw-key.html
       crypto/subtle/aes-gcm-import-raw-key.html
       crypto/workers/subtle/aes-gcm-import-key-decrypt.html
       crypto/workers/subtle/aes-gcm-import-key-encrypt.html
       crypto/workers/subtle/aes-gcm-import-key-unwrap-key.html
       crypto/workers/subtle/aes-gcm-import-key-wrap-key.html

* CMakeLists.txt:
* DerivedSources.make:
* PlatformGTK.cmake:
* PlatformMac.cmake:
Add CryptoAlgorithmAES_CFBMac.cpp as well.
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::normalizeCryptoAlgorithmParameters):
Add support for AES-GCM.
* crypto/CommonCryptoUtilities.h:
Include SPI header for AES-GCM support.
* crypto/CryptoAlgorithmParameters.h:
* crypto/algorithms/CryptoAlgorithmAES_GCM.cpp: Added.
(WebCore::usagesAreInvalidForCryptoAlgorithmAES_GCM):
(WebCore::tagLengthIsValid):
(WebCore::CryptoAlgorithmAES_GCM::create):
(WebCore::CryptoAlgorithmAES_GCM::identifier):
(WebCore::CryptoAlgorithmAES_GCM::encrypt):
(WebCore::CryptoAlgorithmAES_GCM::decrypt):
(WebCore::CryptoAlgorithmAES_GCM::generateKey):
(WebCore::CryptoAlgorithmAES_GCM::importKey):
(WebCore::CryptoAlgorithmAES_GCM::exportKey):
* crypto/algorithms/CryptoAlgorithmAES_GCM.h: Added.
* crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp: Added.
(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
* crypto/mac/CryptoAlgorithmAES_GCMMac.cpp: Added.
(WebCore::encryptAES_GCM):
(WebCore::decyptAES_GCM):
(WebCore::CryptoAlgorithmAES_GCM::platformEncrypt):
(WebCore::CryptoAlgorithmAES_GCM::platformDecrypt):
* crypto/mac/CryptoAlgorithmRegistryMac.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
* crypto/parameters/AesGcmParams.idl: Added.
* crypto/parameters/CryptoAlgorithmAesGcmParams.h: Added.

LayoutTests:

This patch also adds some tests for AES-CFB.

* crypto/subtle/aes-export-key-malformed-parameters-expected.txt:
* crypto/subtle/aes-export-key-malformed-parameters.html:
* crypto/subtle/aes-gcm-decrypt-malformed-parameters-expected.txt: Added.
* crypto/subtle/aes-gcm-decrypt-malformed-parameters.html: Added.
* crypto/subtle/aes-gcm-encrypt-malformed-parameters-expected.txt: Added.
* crypto/subtle/aes-gcm-encrypt-malformed-parameters.html: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-128-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-128.html: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-192-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-192.html: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-256-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-export-key-jwk-length-256.html: Added.
* crypto/subtle/aes-gcm-generate-export-raw-key-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-export-raw-key.html: Added.
* crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-key-encrypt-decrypt.html: Added.
* crypto/subtle/aes-gcm-generate-key-expected.txt: Added.
* crypto/subtle/aes-gcm-generate-key.html: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-128-expected.txt: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-128.html: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-192-expected.txt: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-192.html: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-256-expected.txt: Added.
* crypto/subtle/aes-gcm-import-jwk-key-length-256.html: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-additional-data-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32.html: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-additional-data.html: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-tagLengths-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-decrypt-tagLengths.html: Added.
* crypto/subtle/aes-gcm-import-key-decrypt.html: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-additional-data-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32.html: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-additional-data.html: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-tagLengths-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-encrypt-tagLengths.html: Added.
* crypto/subtle/aes-gcm-import-key-encrypt.html: Added.
* crypto/subtle/aes-gcm-import-key-unwrap-jwk-key-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-unwrap-jwk-key.html: Added.
* crypto/subtle/aes-gcm-import-key-unwrap-raw-key-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-unwrap-raw-key.html: Added.
* crypto/subtle/aes-gcm-import-key-wrap-jwk-key-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-wrap-jwk-key.html: Added.
* crypto/subtle/aes-gcm-import-key-wrap-raw-key-expected.txt: Added.
* crypto/subtle/aes-gcm-import-key-wrap-raw-key.html: Added.
* crypto/subtle/aes-gcm-import-raw-key-expected.txt: Added.
* crypto/subtle/aes-gcm-import-raw-key.html: Added.
* crypto/subtle/aes-generate-key-malformed-parameters-expected.txt:
* crypto/subtle/aes-generate-key-malformed-parameters.html:
* crypto/subtle/aes-import-key-malformed-parameters-expected.txt:
* crypto/subtle/aes-import-key-malformed-parameters.html:
* crypto/workers/subtle/aes-gcm-import-key-decrypt-expected.txt: Added.
* crypto/workers/subtle/aes-gcm-import-key-decrypt.html: Added.
* crypto/workers/subtle/aes-gcm-import-key-encrypt-expected.txt: Added.
* crypto/workers/subtle/aes-gcm-import-key-encrypt.html: Added.
* crypto/workers/subtle/aes-gcm-import-key-unwrap-key-expected.txt: Added.
* crypto/workers/subtle/aes-gcm-import-key-unwrap-key.html: Added.
* crypto/workers/subtle/aes-gcm-import-key-wrap-key-expected.txt: Added.
* crypto/workers/subtle/aes-gcm-import-key-wrap-key.html: Added.
* crypto/workers/subtle/resources/aes-gcm-import-key-decrypt.js: Added.
* crypto/workers/subtle/resources/aes-gcm-import-key-encrypt.js: Added.
* crypto/workers/subtle/resources/aes-gcm-import-key-unwrap-key.js: Added.
* crypto/workers/subtle/resources/aes-gcm-import-key-wrap-key.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213301 268f45cc-cd09-0410-ab3c-d52691b4dbfc
92 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/aes-export-key-malformed-parameters-expected.txt
LayoutTests/crypto/subtle/aes-export-key-malformed-parameters.html
LayoutTests/crypto/subtle/aes-gcm-decrypt-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-decrypt-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-encrypt-malformed-parameters-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-encrypt-malformed-parameters.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-128-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-128.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-192-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-192.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-key-jwk-length-256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-export-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-key-encrypt-decrypt.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-generate-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-128-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-128.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-192-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-192.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-256-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-jwk-key-length-256.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-additional-data-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-additional-data-tag-length-32.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-additional-data.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-tagLengths-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt-tagLengths.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-decrypt.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-additional-data-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-additional-data-tag-length-32.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-additional-data.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-tagLengths-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt-tagLengths.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-jwk-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-jwk-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-unwrap-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-wrap-jwk-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-wrap-jwk-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-wrap-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-key-wrap-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-raw-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-gcm-import-raw-key.html [new file with mode: 0644]
LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters-expected.txt
LayoutTests/crypto/subtle/aes-generate-key-malformed-parameters.html
LayoutTests/crypto/subtle/aes-import-key-malformed-parameters-expected.txt
LayoutTests/crypto/subtle/aes-import-key-malformed-parameters.html
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-decrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-decrypt.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-encrypt-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-encrypt.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-unwrap-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-unwrap-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-wrap-key-expected.txt [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/aes-gcm-import-key-wrap-key.html [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-gcm-import-key-decrypt.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-gcm-import-key-encrypt.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-gcm-import-key-unwrap-key.js [new file with mode: 0644]
LayoutTests/crypto/workers/subtle/resources/aes-gcm-import-key-wrap-key.js [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/encrypt_decrypt/aes_gcm.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/encrypt_decrypt/test_aes_gcm-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_AES-GCM.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_AES-GCM.worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_AES-GCM-expected.txt
LayoutTests/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_AES-GCM-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/JSSubtleCryptoCustom.cpp
Source/WebCore/crypto/CommonCryptoUtilities.h
Source/WebCore/crypto/CryptoAlgorithmParameters.h
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.cpp [new file with mode: 0644]
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_GCM.h [new file with mode: 0644]
Source/WebCore/crypto/gnutls/CryptoAlgorithmAES_GCMGnuTLS.cpp [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmAES_GCMMac.cpp [new file with mode: 0644]
Source/WebCore/crypto/mac/CryptoAlgorithmRegistryMac.cpp
Source/WebCore/crypto/parameters/AesGcmParams.idl [new file with mode: 0644]
Source/WebCore/crypto/parameters/CryptoAlgorithmAesGcmParams.h [new file with mode: 0644]