Skip to content

Stdlib: openssl_get_cipher_methods()/openssl_get_md_methods()/openssl_cipher_iv_length()/openssl_digest() — introspection missing (ext/openssl, phase 1) #6228

Closed

Description

@PurHur

Category

stdlib

Problem

OpenSSL introspection and one-shot digest helpers from ext/openssl are missing. function_exists() is false for all four. Full encrypt/decrypt is tracked in #3324; these smaller entry points are required for typical crypto code paths (cipher list, IV sizing, standalone openssl_digest() without going through hash()).

php-src reference

  • php/php-src ext/openssl/openssl.c — PHP_FUNCTION(openssl_get_cipher_methods), openssl_get_md_methods, openssl_cipher_iv_length, openssl_digest
  • IV length: EVP_CIPHER_iv_length(); digest: EVP_Digest*

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_openssl_introspect.php'
openssl_get_cipher_methods: no
openssl_get_md_methods: no
openssl_cipher_iv_length: no
openssl_digest: no

Zend reference:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php test/repro/maintainer_openssl_introspect.php'
Call Expected (Zend)
openssl_cipher_iv_length('aes-256-cbc') 16
openssl_digest('data', 'sha256') 64-char hex string
in_array('aes-256-cbc', openssl_get_cipher_methods()) true

Scope (this repo)

Path Work
ext/openssl/ or ext/standard/VmOpenSsl*.php PHP implementations; thin OpenSSL ABI in runtime/ only if unavoidable
ext/standard/Module.php or new ext/openssl/Module.php Register four functions
lib/JIT/Builtin/ JIT stubs or VM-only per matrix
Tests test/compliance/cases/stdlib/openssl_digest.phpt, openssl_cipher_iv_length.phpt

Done when

  • Repro prints yes for all four functions
  • openssl_cipher_iv_length + openssl_digest outputs match Zend on Linux Docker
  • Unknown cipher/method returns false with E_WARNING like php-src
  • ./script/ci-fast.sh --filter openssl_digest green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter openssl_digest'

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 5, 2026
  2. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run

  3. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    Merged via #8025.

    PHP-in-PHP: openssl_get_cipher_methods(), openssl_get_md_methods(), openssl_digest() implemented in ext/openssl/OpensslCipherRegistry.php + VmOpenssl.php (cipher IV table + VmHashNative digests). Dropped host function_exists('openssl_cipher_iv_length') delegation.

    C runtime: 0 lines added; host bridge removed from VmOpenssl.php.

    Verification:
    ```bash
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
    php bin/vm.php test/repro/maintainer_openssl_introspect.php
    vendor/bin/phpunit --filter "OpensslModuleTest|VmOpensslRuntimeShrinkTest|openssl_digest|openssl_get_cipher_methods|openssl_cipher_iv_length"
    '
    ```
    OK (13 tests, 28 assertions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions