Skip to content

Stdlib: crypt() — VM + AOT bcrypt via libcrypt (#3771) - #3948

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-3771-crypt
May 31, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-3771-crypt

Conversation

@PurHur

@PurHur PurHur commented May 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Register crypt() on VM (delegates to host PHP php_crypt()), JIT, and AOT via __compiler_crypt in lib/AOT/runtime/password_crypto.c
  • Export CRYPT_STD_DES, CRYPT_EXT_DES, CRYPT_MD5, CRYPT_BLOWFISH constants
  • Invalid/unknown salt returns *0 sentinel matching php-src ext/standard/crypt.c

php-src reference: ext/standard/crypt.c — PHP_FUNCTION(crypt), php_crypt()

Closes #3771

Verification

Issue repro:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "echo function_exists(\"crypt\")?\"yes\":\"no\";"'
# yes

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "\$s=\"\$2y\$10\$\".str_repeat(\"a\",22); echo crypt(\"secret\",\$s), PHP_EOL;"'
# 60-char bcrypt hash starting with $2y$10$

Targeted tests:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "VMTest::testCases.*crypt|PasswordBuiltinTest|AotTest.*crypt"'
# OK (5 tests, 14 assertions)

Compare Zend PHP 8.2 on same snippet — bcrypt prefix/format matches; invalid salt ('', '$2y$10$', '!!!') returns *0.

Made with Cursor

Register crypt() with CRYPT_* constants and php-src-compatible *0
failure sentinel; reuse password_crypto.c for JIT/AOT lowering.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 49e6ef9 into master May 31, 2026
@PurHur
PurHur deleted the agent/issue-3771-crypt branch May 31, 2026 20:00
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: crypt() — POSIX DES/BCRYPT string hashing (ext/standard/password.c parity)

1 participant