Skip to content

Stdlib: openssl_pkey_new() JIT/AOT happy-path leftover of #33530 — OpenSSLAsymmetricKey object AOT (ext/openssl/openssl.c) #34015

Description

@PurHur

Category

bug · AOT unimplemented · php-src-strict · leftover of #33530 / #6295

Problem

#33530 baked catchable argc/TypeError paths for openssl_pkey_new(), but the happy path still throws at compile time:

openssl_pkey_new() is not implemented for JIT in this compiler build (issue #6295/#22335/#33530)

VM matches Zend (OpenSSLAsymmetricKey + exportable PEM). Thin AOT cannot compile keygen, which blocks real TLS/crypto programs.

Repro Zend 8.2+ / VM AOT thin (master @ e861c86)
echo get_class(openssl_pkey_new()); OpenSSLAsymmetricKey compile LogicException
openssl_pkey_new(null) object compile LogicException
openssl_pkey_new(['private_key_bits'=>512]) object wrong runtime TypeError (mixed) or LogicException

./script/aot-smoke.sh is 8/8 — feature gap, not the linker.

php-src reference

PHP implementation target

  • ext/openssl/openssl_pkey_new.php — replace happy-path LogicException with NestedJIT/object bake (peer hash_init / HashContext)
  • Store PEM on OpenSSLAsymmetricKey (property or side-channel readable from AOT); update VmOpensslObjects::keyPem()
  • Prefer PHP-in-PHP + existing VmOpensslPkeyNative::generateRsa — no new runtime/*.c

Repro

./script/docker-exec.sh -- bash -lc 'printf "%s\n" "<?php" "\$k = openssl_pkey_new();" "echo get_class(\$k), PHP_EOL;" > /tmp/pk.php; php bin/compile.php -o /tmp/pk.bin /tmp/pk.php && /tmp/pk.bin'

Done when

  • AOT get_class(openssl_pkey_new()) prints OpenSSLAsymmetricKey (rc=0)
  • AOT openssl_pkey_new(null) same
  • Keys differ across process runs (runtime generation, not compile-time constant)
  • ./script/aot-smoke.sh stays 8/8
  • Repro under test/repro/

Parent

Activity

  1. added
    bugSomething isn't working
    phase-4:stdlibPhase 4 – stdlib for web apps
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Aug 23, 2026
  2. PurHur commented on Aug 23, 2026

    @PurHur
    OwnerAuthor

    claim: I/O-crypto-text lane — north-star #32122/#31968 closed; implementing openssl_pkey_new happy-path NestedJIT + OpenSSLAsymmetricKey PEM property AOT (#34015 leftover of #33530).

  3. PurHur commented on Aug 23, 2026

    @PurHur
    OwnerAuthor

    claim: stdlib+AOT builtins lane — continuing #34015 (prior I/O-crypto claim, no branch/PR yet). Implementing openssl_pkey_new happy-path NestedJIT + OpenSSLAsymmetricKey AOT.

  4. PurHur commented on Aug 23, 2026

    @PurHur
    OwnerAuthor

    Reopening: #34023 closed this with a compile-time PEM bake for thin AOT (JitOpensslPkeyNew::generateThinAotBaked). That fails Done-when “Keys differ across process runs (runtime generation, not compile-time constant)”.

    Verified on master @ a767add:

    • strings on the AOT binary shows BEGIN PRIVATE KEY (two baked PEMs for the two calls)
    • nm has no EVP_PKEY_keygen
    • get_class works, but every process run shares the compile-time key material

    Fix: runtime libcrypto EVP_PKEY_keygen leaf (peer JitOpensslSignKernel), not NestedJIT FFI / bake.

  5. reopened this on Aug 23, 2026
  6. PurHur commented on Aug 23, 2026

    @PurHur
    OwnerAuthor

    claim: stdlib+AOT builtins — replacing thin-AOT compile-time PEM bake with runtime EVP_PKEY_keygen LLVM leaf so keys differ across process runs (#34015 Done-when).

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:compilerCompiler / CFG / JITbugSomething isn't workingimplementation-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