Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[GCrypt] Add support for P-521 EC curves
https://bugs.webkit.org/show_bug.cgi?id=175199 Reviewed by Jiewen Tan. Source/WebCore: Add support for 521-bit elliptic curves in the libgcrypt-based implementation of WebCrypto API. In the CryptoAlgorithmECDH implementation, the bit-size of the key is now rounded up to the next byte boundary and passed to the helper gcryptDerive() function. There the size in bytes is used to zero-pad the derived key data. This is done to properly handle derivation results for the P-521 curves, where the leading zero bit could get clipped, resulting in a derived key that is only 65 byes in length when it is expected to be 66 bytes. Further cleanups are done in gcryptDerive() to use the mpiData() function where possible. In the CryptoAlgorithmECDSA implementation, the bit-size of the key is again rounded up to the nearest byte boundary before being passed to the helper gcryptSign() and gcryptVerify() functions. This again properly enforces the requirement of 66 bytes to handle P-521 elliptic curves. In the CryptoKeyEC implementation, NamedCurve::P521 cases in helper functions operating on NamedCurve values are now implemented to return appropriate values. platformSupportedCurve() now returns true for the NamedCurve::P521 value. Zero-padding of the private key data is used wherever it is necessary to avoid clipping any leading zero bit in the P-521 EC key. No new tests -- affected tests have their baselines updated. * crypto/gcrypt/CryptoAlgorithmECDHGCrypt.cpp: (WebCore::gcryptDerive): (WebCore::CryptoAlgorithmECDH::platformDeriveBits): * crypto/gcrypt/CryptoAlgorithmECDSAGCrypt.cpp: (WebCore::CryptoAlgorithmECDSA::platformSign): (WebCore::CryptoAlgorithmECDSA::platformVerify): * crypto/gcrypt/CryptoKeyECGCrypt.cpp: (WebCore::curveName): (WebCore::curveIdentifier): (WebCore::curveSize): (WebCore::curveUncompressedFieldElementSize): (WebCore::CryptoKeyEC::platformSupportedCurve): (WebCore::curveForIdentifier): (WebCore::CryptoKeyEC::platformImportPkcs8): (WebCore::CryptoKeyEC::platformAddFieldElements const): (WebCore::CryptoKeyEC::platformExportPkcs8 const): LayoutTests: Add or update Web Crypto test baselines for the GTK+ and WPE ports to reflect the added EC P-521 support. * platform/gtk/crypto/subtle/ec-generate-key-malformed-parameters-expected.txt: Added. * platform/gtk/crypto/subtle/ecdh-derive-bits-length-limits-expected.txt: Added. * platform/gtk/crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_keys.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures.worker-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_ECDH.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_ECDSA.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes.worker-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_ECDH.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_ECDSA.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures.https-expected.txt: * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDH.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDSA.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDH.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDSA.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey.https-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/sign_verify/ecdsa.worker-expected.txt: Added. * platform/gtk/imported/w3c/web-platform-tests/WebCryptoAPI/sign_verify/test_ecdsa.https-expected.txt: Added. * platform/wpe/crypto/subtle/ec-generate-key-malformed-parameters-expected.txt: Added. * platform/wpe/crypto/subtle/ecdh-derive-bits-length-limits-expected.txt: Added. * platform/wpe/crypto/subtle/ecdh-import-spki-key-ecdh-identifier-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_bits.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/ecdh_keys.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_bits.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/test_ecdh_keys.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures.worker-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_ECDH.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_ECDSA.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes.worker-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_ECDH.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_ECDSA.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures.https-expected.txt: * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDH.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_failures_ECDSA.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDH.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/test_successes_ECDSA.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/ec_importKey.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/test_ec_importKey.https-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/sign_verify/ecdsa.worker-expected.txt: Added. * platform/wpe/imported/w3c/web-platform-tests/WebCryptoAPI/sign_verify/test_ecdsa.https-expected.txt: Added. Canonical link: https://commits.webkit.org/195138@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224173 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information