@@ -469,92 +469,6 @@ zend_result php_openssl_write_rand_file(const char * file, int egdsocket, int se
469469 return SUCCESS ;
470470}
471471
472- EVP_MD * php_openssl_get_evp_md_from_algo (zend_long algo ) {
473- EVP_MD * mdtype ;
474-
475- switch (algo ) {
476- case OPENSSL_ALGO_SHA1 :
477- mdtype = (EVP_MD * ) EVP_sha1 ();
478- break ;
479- case OPENSSL_ALGO_MD5 :
480- mdtype = (EVP_MD * ) EVP_md5 ();
481- break ;
482- #ifndef OPENSSL_NO_MD4
483- case OPENSSL_ALGO_MD4 :
484- mdtype = (EVP_MD * ) EVP_md4 ();
485- break ;
486- #endif
487- #ifndef OPENSSL_NO_MD2
488- case OPENSSL_ALGO_MD2 :
489- mdtype = (EVP_MD * ) EVP_md2 ();
490- break ;
491- #endif
492- case OPENSSL_ALGO_SHA224 :
493- mdtype = (EVP_MD * ) EVP_sha224 ();
494- break ;
495- case OPENSSL_ALGO_SHA256 :
496- mdtype = (EVP_MD * ) EVP_sha256 ();
497- break ;
498- case OPENSSL_ALGO_SHA384 :
499- mdtype = (EVP_MD * ) EVP_sha384 ();
500- break ;
501- case OPENSSL_ALGO_SHA512 :
502- mdtype = (EVP_MD * ) EVP_sha512 ();
503- break ;
504- #ifndef OPENSSL_NO_RMD160
505- case OPENSSL_ALGO_RMD160 :
506- mdtype = (EVP_MD * ) EVP_ripemd160 ();
507- break ;
508- #endif
509- default :
510- return NULL ;
511- break ;
512- }
513- return mdtype ;
514- }
515-
516- const EVP_CIPHER * php_openssl_get_evp_cipher_from_algo (zend_long algo ) {
517- switch (algo ) {
518- #ifndef OPENSSL_NO_RC2
519- case PHP_OPENSSL_CIPHER_RC2_40 :
520- return EVP_rc2_40_cbc ();
521- break ;
522- case PHP_OPENSSL_CIPHER_RC2_64 :
523- return EVP_rc2_64_cbc ();
524- break ;
525- case PHP_OPENSSL_CIPHER_RC2_128 :
526- return EVP_rc2_cbc ();
527- break ;
528- #endif
529-
530- #ifndef OPENSSL_NO_DES
531- case PHP_OPENSSL_CIPHER_DES :
532- return EVP_des_cbc ();
533- break ;
534- case PHP_OPENSSL_CIPHER_3DES :
535- return EVP_des_ede3_cbc ();
536- break ;
537- #endif
538-
539- #ifndef OPENSSL_NO_AES
540- case PHP_OPENSSL_CIPHER_AES_128_CBC :
541- return EVP_aes_128_cbc ();
542- break ;
543- case PHP_OPENSSL_CIPHER_AES_192_CBC :
544- return EVP_aes_192_cbc ();
545- break ;
546- case PHP_OPENSSL_CIPHER_AES_256_CBC :
547- return EVP_aes_256_cbc ();
548- break ;
549- #endif
550-
551-
552- default :
553- return NULL ;
554- break ;
555- }
556- }
557-
558472void php_openssl_backend_init (void )
559473{
560474#ifdef LIBRESSL_VERSION_NUMBER
@@ -1931,7 +1845,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
19311845 PHP_OPENSSL_CHECK_LONG_TO_INT_NULL_RETURN (tag_len , tag_len );
19321846
19331847
1934- cipher_type = EVP_get_cipherbyname (method );
1848+ cipher_type = php_openssl_get_evp_cipher_by_name (method );
19351849 if (!cipher_type ) {
19361850 php_error_docref (NULL , E_WARNING , "Unknown cipher algorithm" );
19371851 return NULL ;
@@ -2023,7 +1937,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
20231937 PHP_OPENSSL_CHECK_SIZE_T_TO_INT_NULL_RETURN (tag_len , tag );
20241938
20251939
2026- cipher_type = EVP_get_cipherbyname (method );
1940+ cipher_type = php_openssl_get_evp_cipher_by_name (method );
20271941 if (!cipher_type ) {
20281942 php_error_docref (NULL , E_WARNING , "Unknown cipher algorithm" );
20291943 return NULL ;
@@ -2079,11 +1993,11 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
20791993 return outbuf ;
20801994}
20811995
2082- const EVP_CIPHER * php_openssl_get_evp_cipher_by_name (const char * method )
1996+ const EVP_CIPHER * php_openssl_get_evp_cipher_by_name_with_warning (const char * method )
20831997{
20841998 const EVP_CIPHER * cipher_type ;
20851999
2086- cipher_type = EVP_get_cipherbyname (method );
2000+ cipher_type = php_openssl_get_evp_cipher_by_name (method );
20872001 if (!cipher_type ) {
20882002 php_error_docref (NULL , E_WARNING , "Unknown cipher algorithm" );
20892003 return NULL ;
@@ -2095,14 +2009,14 @@ const EVP_CIPHER *php_openssl_get_evp_cipher_by_name(const char *method)
20952009
20962010PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length (const char * method )
20972011{
2098- const EVP_CIPHER * cipher_type = php_openssl_get_evp_cipher_by_name (method );
2012+ const EVP_CIPHER * cipher_type = php_openssl_get_evp_cipher_by_name_with_warning (method );
20992013
21002014 return cipher_type == NULL ? -1 : EVP_CIPHER_iv_length (cipher_type );
21012015}
21022016
21032017PHP_OPENSSL_API zend_long php_openssl_cipher_key_length (const char * method )
21042018{
2105- const EVP_CIPHER * cipher_type = php_openssl_get_evp_cipher_by_name (method );
2019+ const EVP_CIPHER * cipher_type = php_openssl_get_evp_cipher_by_name_with_warning (method );
21062020
21072021 return cipher_type == NULL ? -1 : EVP_CIPHER_key_length (cipher_type );
21082022}
0 commit comments