Edit report at https://bugs.php.net/bug.php?id=65157&edit=1
ID: 65157 Updated by: a...@php.net Reported by: eugene at zhegan dot in Summary: openssl module doesn't see all available ciphers -Status: Open +Status: Feedback Type: Bug Package: OpenSSL related PHP Version: 5.3.26 Block user comment: N Private report: N New Comment: I really doubt the reported issue has something to do with PHP. Looking at the code behind openssl_digest - PHP is just a wrapper, the lookup for a digest method is done by the openssl library. See http://lxr.php.net/xref/PHP_5_3/ext/openssl/openssl.c#4594 Could you please check whether PHP is linked with the openssl instance you expect? Also whether the correct .so is used on runtime. Please be aware also - some engines can require to be loaded and configured through openssl.cnf, be sure the right config file is used. Previous Comments: ------------------------------------------------------------------------ [2013-06-28 10:15:50] eugene at zhegan dot in Description: ------------ Openssl doesn't see al available ciphers. In order to not get bored, please read the last part, and then, if you are still not bored, you can read following part, in order to understand how to get GOST ciphers in PHP. Missing cipher is GOST R 34.10-2001. BORING PART: I have an fresh upstream OpenSLL, which now is by default built with GOST encryption. I want to use GOST encryption (actually, I have to use it, because I'm from Russia, and FSB/KGB/God knows who is forcing to use it). OpenSSL > 1.0.0 is built with GOST encryption, but in order to actually enable it, you have to use a configuration file which mentions it. This is the first problem, still unresolved in the PHP, howevere there are several workarounds (all of the contail OPENSSL_config() call added somewhere). I have a curl from upstream built with OPENSSL_config() call, and a curl PHP module loaded before openssl module (so, no openssl modifuication is needed). NOT SO BORING PART: Why I think it's missing: Because openssl has it: /usr/local/openssl/bin/openssl ciphers aGOST01 GOST2001-GOST89-GOST89:GOST2001-NULL-GOST94 (according to its manual - "aGOST01 - cipher suites using GOST R 34.10-2001 authentication.") Curl also has it: /usr/local/curl/bin/curl --engine gost --ciphers GOST2001-GOST89-GOST89 https://google.com curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure I got a failure, but when the non-existent cipher suite is used, the error is different: /usr/local/curl/bin/curl --engine gost --ciphers GOST2001-GOST89-GOST666 https://google.com curl: (59) failed setting cipher list So, openssl has it, curl has it, but for some reason php doesn't. openssl_get_md_methods() shows a couple of GOST digest but not GOST R 34.11-94: array(30) { [0]=> string(3) "DSA" [1]=> string(7) "DSA-SHA" [2]=> string(17) "GOST 28147-89 MAC" [3]=> string(15) "GOST R 34.11-94" [4]=> string(3) "MD4" [5]=> string(3) "MD5" [6]=> string(4) "MDC2" [7]=> string(9) "RIPEMD160" [8]=> string(3) "SHA" [9]=> string(4) "SHA1" [10]=> string(6) "SHA224" [11]=> string(6) "SHA256" [12]=> string(6) "SHA384" [13]=> string(6) "SHA512" [14]=> string(13) "dsaEncryption" [15]=> string(10) "dsaWithSHA" [16]=> string(15) "ecdsa-with-SHA1" [17]=> string(8) "gost-mac" [18]=> string(3) "md4" [19]=> string(3) "md5" [20]=> string(9) "md_gost94" [21]=> string(4) "mdc2" [22]=> string(9) "ripemd160" [23]=> string(3) "sha" [24]=> string(4) "sha1" [25]=> string(6) "sha224" [26]=> string(6) "sha256" [27]=> string(6) "sha384" [28]=> string(6) "sha512" [29]=> string(9) "whirlpool" The code $encres = openssl_digest("123", "GOST R 34.11-94"); echo $encres; gives this: 5ef18489617ba2d8d2d7e0da389aaa4ff022ad01a39512a4fea1a8c45e439148 And the code: encres = openssl_digest("123", "GOST R 34.10-2001"); echo $encres; gives this: PHP Warning: openssl_digest(): Unknown signature algorithm in /home/emz/ciphers.php on line 6 Test script: --------------- <?php var_dump(openssl_get_md_methods()); var_dump(hash_algos()); $encres = openssl_digest("123", "GOST R 34.10-2001"); echo $encres; ?> Expected result: ---------------- I expect GOST R 34.10-2001 to be shown in the cipher list and openssl_digest() gives me encrypted string. Actual result: -------------- In fact, GOST R 34.10-2001 is not shown in the output of the openssl_get_md_methods(), and openssl_digest() is giving me the error: PHP Warning: openssl_digest(): Unknown signature algorithm in /home/emz/ciphers.php on line 6 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65157&edit=1