Skip to content

Stdlib: crypt() — POSIX DES/BCRYPT string hashing (ext/standard/password.c parity) #3771

Description

@PurHur

Category

stdlib

Problem

crypt() is not registered. Zend exposes the legacy one-way hash API (CRYPT_STD_DES, CRYPT_EXT_DES, CRYPT_MD5, CRYPT_BLOWFISH). This compiler implements password_hash() / password_verify() via libcrypt in AOT (lib/AOT/runtime/password_crypto.c) but does not expose the standalone crypt() builtin.

php-src reference

Repro (failure today)

<?php
$salt = '$2y$10$' . str_repeat('a', 22);
echo crypt('secret', $salt), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "echo function_exists(\"crypt\")?\"yes\":\"no\";"'
# no

Zend PHP 8.x: 60-char bcrypt hash string
This compiler (VM): fatal — undefined function crypt

Scope (this repo)

Layer Files Notes
VM ext/standard/crypt.php, ext/standard/VmPassword.php (reuse libcrypt helpers) Delegate to host crypt(3) or reuse AOT runtime
JIT/AOT ext/standard/JitPassword.php / lib/AOT/runtime/password_crypto.c Share setting validation with password_hash()
Register ext/standard/Module.php Export CRYPT_* constants
Tests test/compliance/cases/stdlib/crypt.phpt Bcrypt salt round-trip subset

Done when

  • function_exists('crypt') is true on VM
  • Repro prints a bcrypt hash matching Zend prefix/format for the same salt
  • Invalid salt emits PHP Warning and returns * sentinel (Zend parity)
  • ./script/ci-fast.sh --filter crypt green
  • docs/capabilities.md row for crypt

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php  # compare output

Links

Activity

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