[webkit-changes] [WebKit/WebKit] 0dab8b: [GTK] Implement the X25519 algorithm

Javier Fernandez Garcia-Boente noreply at github.com
Sun Sep 3 23:45:52 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0dab8bb6c4d71fb6c3072859b974642a6cf7487a
      https://github.com/WebKit/WebKit/commit/0dab8bb6c4d71fb6c3072859b974642a6cf7487a
  Author: Javier Fernandez <jfernandez at igalia.com>
  Date:   2023-09-03 (Sun, 03 Sep 2023)

  Changed paths:
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.https.any.worker-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.https.any.worker-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.worker-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.worker-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.worker-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any-expected.txt
    A LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.worker-expected.txt
    M Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
    M Source/WebCore/CMakeLists.txt
    M Source/WebCore/DerivedSources-input.xcfilelist
    M Source/WebCore/DerivedSources-output.xcfilelist
    M Source/WebCore/DerivedSources.make
    M Source/WebCore/Sources.txt
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/bindings/js/SerializedScriptValue.cpp
    M Source/WebCore/crypto/CryptoAlgorithmIdentifier.h
    M Source/WebCore/crypto/CryptoAlgorithmParameters.h
    M Source/WebCore/crypto/SubtleCrypto.cpp
    A Source/WebCore/crypto/algorithms/CryptoAlgorithmX25519.cpp
    A Source/WebCore/crypto/algorithms/CryptoAlgorithmX25519.h
    M Source/WebCore/crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp
    A Source/WebCore/crypto/gcrypt/CryptoAlgorithmX25519GCrypt.cpp
    M Source/WebCore/crypto/gcrypt/CryptoKeyOKPGCrypt.cpp
    A Source/WebCore/crypto/gcrypt/GCryptRFC7748.cpp
    A Source/WebCore/crypto/gcrypt/GCryptRFC7748.h
    M Source/WebCore/crypto/gcrypt/GCryptUtilities.h
    M Source/WebCore/crypto/keys/CryptoKeyOKP.cpp
    M Source/WebCore/crypto/keys/CryptoKeyOKP.h
    M Source/WebCore/crypto/mac/CryptoKeyOKPCocoa.cpp
    A Source/WebCore/crypto/parameters/CryptoAlgorithmX25519Params.h
    A Source/WebCore/crypto/parameters/X25519Params.idl
    M Source/WebCore/platform/SourcesGCrypt.txt

  Log Message:
  -----------
  [GTK] Implement the X25519 algorithm
https://bugs.webkit.org/show_bug.cgi?id=249017

Reviewed by Youenn Fablet and Žan Doberšek.

This change implements all the X25519's operations defined in the
WebCrypto Secure Curves specification. These operations include the
key generation, import/export in spki, pkcs8 and jwk formats and the
deriveKey and deriveBits methods that are the key operations of this
algorithm.

The main WebCrypto API implementation of the GTK+ port is based on
the Libgcrypt primitives. There is an ongoing effort to implement it
in OpenSSL (see bug 248980 for details) but it won't be an option for
the GTK+ port in the short term.

A new utility class has been added to the GCrypt based implementation
of the WebCrypto API, named as GCryptRFC7748. It implements the a function
to perform scalar multiplication on the Montgomery form of the Curve25519
and Curve488 curves. However, it only defines the X25519 function since
we don't support the X488 algorithm for now.

The feature is implemented behind a runtime flag, hence this PR adds a
new item in the UnifiedWebPreferences file as 'WebCryptoX25519Enabled'
with 'testable' status.

* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_bits.https.any.worker-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/derive_bits_keys/cfrg_curves_keys.https.any.worker-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/failures_X25519.https.any.worker-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/generateKey/successes_X25519.https.any.worker-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey.https.any.worker-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any-expected.txt: Added.
* LayoutTests/platform/glib/imported/w3c/web-platform-tests/WebCryptoAPI/import_export/okp_importKey_failures_X25519.https.any.worker-expected.txt: Added.
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::write):
(WebCore::CloneDeserializer::read):
* Source/WebCore/crypto/CryptoAlgorithmIdentifier.h:
* Source/WebCore/crypto/CryptoAlgorithmParameters.h:
* Source/WebCore/crypto/SubtleCrypto.cpp:
(WebCore::isX25519Enabled):
(WebCore::normalizeCryptoAlgorithmParameters):
(WebCore::isSupportedExportKey):
* Source/WebCore/crypto/algorithms/CryptoAlgorithmX25519.cpp: Added.
(WebCore::CryptoAlgorithmX25519::create):
(WebCore::CryptoAlgorithmX25519::identifier const):
(WebCore::CryptoAlgorithmX25519::generateKey):
(WebCore::CryptoAlgorithmX25519::platformDeriveBits):
(WebCore::CryptoAlgorithmX25519::deriveBits):
(WebCore::CryptoAlgorithmX25519::importKey):
(WebCore::CryptoAlgorithmX25519::exportKey):
* Source/WebCore/crypto/algorithms/CryptoAlgorithmX25519.h: Added.
* Source/WebCore/crypto/gcrypt/CryptoAlgorithmRegistryGCrypt.cpp:
(WebCore::CryptoAlgorithmRegistry::platformRegisterAlgorithms):
* Source/WebCore/crypto/gcrypt/CryptoAlgorithmX25519GCrypt.cpp: Added.
(WebCore::gcryptDerive):
(WebCore::CryptoAlgorithmX25519::platformDeriveBits):
* Source/WebCore/crypto/gcrypt/CryptoKeyOKPGCrypt.cpp:
(WebCore::CryptoKeyOKP::isPlatformSupportedCurve):
(WebCore::CryptoKeyOKPImpl::supportedAlgorithmIdentifier):
(WebCore::CryptoKeyOKP::platformGeneratePair):
(WebCore::CryptoKeyOKP::platformCheckPairedKeys):
(WebCore::CryptoKeyOKP::importSpki):
(WebCore::CryptoKeyOKP::exportSpki const):
(WebCore::CryptoKeyOKP::importPkcs8):
(WebCore::CryptoKeyOKP::exportPkcs8 const):
(WebCore::CryptoKeyOKP::generateJwkX const):
* Source/WebCore/crypto/gcrypt/GCryptRFC7748.cpp: Added.
(WebCore::xImpl):
(WebCore::X25519):
* Source/WebCore/crypto/gcrypt/GCryptRFC7748.h: Added.
* Source/WebCore/crypto/gcrypt/GCryptUtilities.h:
* Source/WebCore/crypto/keys/CryptoKeyOKP.cpp:
(WebCore::CryptoKeyOKP::importRaw):
(WebCore::CryptoKeyOKP::importJwk):
(WebCore::CryptoKeyOKP::platformCheckPairedKeys):
(WebCore::CryptoKeyOKP::platformExportRaw const):
* Source/WebCore/crypto/keys/CryptoKeyOKP.h:
* Source/WebCore/crypto/mac/CryptoKeyOKPCocoa.cpp:
(WebCore::CryptoKeyOKP::platformCheckPairedKeys):
* Source/WebCore/crypto/parameters/CryptoAlgorithmX25519Params.h: Added.
* Source/WebCore/crypto/parameters/X25519Params.idl: Added.
* Source/WebCore/platform/SourcesGCrypt.txt:

Canonical link: https://commits.webkit.org/267602@main




More information about the webkit-changes mailing list