Skip to content

Openssl: openssl_dh_compute_key() — DH shared secret API (#6596)#18620

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6596-openssl-dh-compute-key
Jul 13, 2026
Merged

Openssl: openssl_dh_compute_key() — DH shared secret API (#6596)#18620
PurHur merged 1 commit into
masterfrom
agent/issue-6596-openssl-dh-compute-key

Conversation

@PurHur

@PurHur PurHur commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implement openssl_dh_compute_key() on VM using existing libcrypto FFI (EVP_PKEY_copy_parameters + EVP_PKEY_set1_encoded_public_key + EVP_PKEY_derive), matching php-src ext/openssl/openssl_backend_v3.c.
  • Refactor VmOpensslPkeyDeriveNative::derive() to share deriveWithPeer() with the new DH path.
  • Add compliance PHPT + maintainer repro with fixed DH test vectors.

php-src reference: ext/openssl/openssl_backend_v3.cphp_openssl_dh_compute_key()

Test plan

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_openssl_dh_compute_key.php
php bin/vm.php test/repro-maintainer/parity_openssl_dh_compute_key.php
'
# Zend: ok
# VM:   ok

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter openssl_dh_compute_key'
# OK (2 tests, 2 assertions)

php script/capability-matrix.php
php script/bootstrap-inventory.php --check
./script/check-generated-docs.sh
# all green

Closes #6596

Made with Cursor

Wire DH shared-secret computation via EVP_PKEY_derive on raw peer public
bytes, matching php-src ext/openssl/openssl_backend_v3.c. Reuses the
existing libcrypto FFI bridge; no new C runtime logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit d7f24f1 into master Jul 13, 2026
@PurHur PurHur deleted the agent/issue-6596-openssl-dh-compute-key branch July 13, 2026 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: openssl_dh_compute_key() — Diffie-Hellman shared secret missing (ext/openssl/dh.c)

1 participant