|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-07-11 07:05 UTC] requinix@php.net
Description: ------------ With the libsodium PR merged I did a quick test for functions. php_libsodium.h lists a number of sodium_* functions however some don't have implementations in libsodium.c. (I checked all 61 functions and found only the 8 listed below.) My guess is they should be removed - encrypt/decrypt look like duplicates of the non-'x'ed versions - pwhash gets bundled into password_hash/verify() - randombytes gets bundled into random_bytes() ...but I bet this will be a non-issue when the code gets refactored and cleaned up later anyways. Test script: --------------- Given a file "sodium" containing: sodium_crypto_aead_xchacha20poly1305_ietf_decrypt sodium_crypto_aead_xchacha20poly1305_ietf_encrypt sodium_crypto_pwhash sodium_crypto_pwhash_str sodium_crypto_pwhash_str_verify sodium_randombytes_buf sodium_randombytes_random16 sodium_randombytes_uniform $ xargs -a sodium -l php --rf | grep Exception Expected result: ---------------- No output (all functions found) Actual result: -------------- Exception: Function sodium_crypto_aead_xchacha20poly1305_ietf_decrypt() does not exist Exception: Function sodium_crypto_aead_xchacha20poly1305_ietf_encrypt() does not exist Exception: Function sodium_crypto_pwhash() does not exist Exception: Function sodium_crypto_pwhash_str() does not exist Exception: Function sodium_crypto_pwhash_str_verify() does not exist Exception: Function sodium_randombytes_buf() does not exist Exception: Function sodium_randombytes_random16() does not exist Exception: Function sodium_randombytes_uniform() does not exist PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 17:00:01 2025 UTC |
Yes, what I'm doing does need PHP built --with-sodium, and I do it after the make. It's not as fancy as make test. I took all the functions from php_libsodium.h (just the function names), put them into a file, then ran "php --rf <function>" for each one. --rf will dump a function definition or error if the function is undefined. Linux: /path/to/php-src$ xargs -a list_of_functions.txt -l sapi/cli/php --rf | grep Exception Windows: C:\path\to\php-src> for /f %i in (list_of_functions.txt) do @sapi/cli/php --rf %i | findstr "Exception" But you can ignore it all and just check the code: if the PHP_FEs and PHP_FUNCTIONs in libsodium.c are in #ifdefs then the same PHP_FUNCTIONs in php_libsodium.h should have them too. That does mean moving some #defines out of the .c and into the .h. Compare with what ext/curl does. ext/curl/interface.c has const zend_function_entry curl_functions[] = { ... #if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ PHP_FE(curl_strerror, arginfo_curl_strerror) PHP_FE(curl_multi_strerror, arginfo_curl_multi_strerror) PHP_FE(curl_share_strerror, arginfo_curl_share_strerror) #endif and #if LIBCURL_VERSION_NUM >= 0x070c00 /* Available since 7.12.0 */ /* {{{ proto bool curl_strerror(int code) return string describing error code */ PHP_FUNCTION(curl_strerror) { ... } /* }}} */ #endif To match that, php_curl.h has #if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */ PHP_FUNCTION(curl_strerror); PHP_FUNCTION(curl_multi_strerror); PHP_FUNCTION(curl_share_strerror); #endif