@@ -1553,12 +1553,6 @@ PHP_FUNCTION(openssl_spki_new)
15531553
15541554 PHP_OPENSSL_CHECK_SIZE_T_TO_INT (challenge_len , challenge , 2 );
15551555
1556- mdtype = php_openssl_get_evp_md_from_algo (algo );
1557- if (!mdtype ) {
1558- zend_argument_value_error (3 , "must be a valid signature algorithm" );
1559- RETURN_THROWS ();
1560- }
1561-
15621556 pkey = php_openssl_pkey_from_zval (zpkey , 0 , challenge , challenge_len , & free_pkey );
15631557 if (pkey == NULL ) {
15641558 if (!EG (exception )) {
@@ -1567,6 +1561,13 @@ PHP_FUNCTION(openssl_spki_new)
15671561 goto cleanup ;
15681562 }
15691563
1564+ mdtype = php_openssl_get_evp_md_from_algo (algo );
1565+
1566+ if (!mdtype ) {
1567+ php_error_docref (NULL , E_WARNING , "Unknown signature algorithm" );
1568+ goto cleanup ;
1569+ }
1570+
15701571 if ((spki = NETSCAPE_SPKI_new ()) == NULL ) {
15711572 php_openssl_store_errors ();
15721573 php_error_docref (NULL , E_WARNING , "Unable to create new SPKAC" );
@@ -1851,7 +1852,7 @@ zend_string* php_openssl_x509_fingerprint(X509 *peer, const char *method, zend_b
18511852 zend_string * ret ;
18521853
18531854 if (!(mdtype = EVP_get_digestbyname (method ))) {
1854- zend_value_error ( "Unknown signature algorithm" );
1855+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
18551856 return NULL ;
18561857 } else if (!X509_digest (peer , mdtype , md , & n )) {
18571858 php_openssl_store_errors ();
@@ -3820,7 +3821,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
38203821 break ;
38213822#endif
38223823 default :
3823- zend_value_error ( "Unsupported private key type" );
3824+ php_error_docref ( NULL , E_WARNING , "Unsupported private key type" );
38243825 }
38253826 } else {
38263827 php_openssl_store_errors ();
@@ -4212,7 +4213,7 @@ PHP_FUNCTION(openssl_pkey_new)
42124213 }
42134214
42144215 if (group == NULL ) {
4215- zend_argument_value_error ( 1 , "must be a valid curve name" );
4216+ php_error_docref ( NULL , E_WARNING , "Unknown curve name" );
42164217 goto clean_exit ;
42174218 }
42184219
@@ -4342,10 +4343,9 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
43424343 key = php_openssl_pkey_from_zval (zpkey , 0 , passphrase , passphrase_len , & free_pkey );
43434344 if (key == NULL ) {
43444345 if (!EG (exception )) {
4345- // TypeError?
4346- zend_argument_value_error (1 , "cannot retrieve key" );
4346+ php_error_docref (NULL , E_WARNING , "Cannot get key from parameter 1" );
43474347 }
4348- RETURN_THROWS () ;
4348+ RETURN_FALSE ;
43494349 }
43504350
43514351 if (php_openssl_open_base_dir_chk (filename )) {
@@ -4429,9 +4429,9 @@ PHP_FUNCTION(openssl_pkey_export)
44294429 key = php_openssl_pkey_from_zval (zpkey , 0 , passphrase , passphrase_len , & free_pkey );
44304430 if (key == NULL ) {
44314431 if (!EG (exception )) {
4432- zend_argument_value_error ( 1 , "cannot retrieve key" );
4432+ php_error_docref ( NULL , E_WARNING , "Cannot get key from parameter 1 " );
44334433 }
4434- RETURN_THROWS () ;
4434+ RETURN_FALSE ;
44354435 }
44364436
44374437 PHP_SSL_REQ_INIT (& req );
@@ -4859,8 +4859,8 @@ PHP_FUNCTION(openssl_pbkdf2)
48594859 }
48604860
48614861 if (!digest ) {
4862- zend_argument_value_error ( 5 , "must be a valid signature algorithm" );
4863- RETURN_THROWS () ;
4862+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
4863+ RETURN_FALSE ;
48644864 }
48654865
48664866 out_buffer = zend_string_alloc (key_length , 0 );
@@ -6545,9 +6545,9 @@ PHP_FUNCTION(openssl_sign)
65456545 pkey = php_openssl_pkey_from_zval (key , 0 , "" , 0 , & free_pkey );
65466546 if (pkey == NULL ) {
65476547 if (!EG (exception )) {
6548- zend_argument_type_error ( 3 , " cannot be coerced into a private key" );
6548+ php_error_docref ( NULL , E_WARNING , "Supplied key param cannot be coerced into a private key" );
65496549 }
6550- RETURN_THROWS () ;
6550+ RETURN_FALSE ;
65516551 }
65526552
65536553 if (method == NULL || Z_TYPE_P (method ) == IS_LONG ) {
@@ -6563,8 +6563,8 @@ PHP_FUNCTION(openssl_sign)
65636563 RETURN_THROWS ();
65646564 }
65656565 if (!mdtype ) {
6566- zend_argument_value_error ( 4 , "must be a valid signature algorithm" );
6567- RETURN_THROWS () ;
6566+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
6567+ RETURN_FALSE ;
65686568 }
65696569
65706570 siglen = EVP_PKEY_size (pkey );
@@ -6613,15 +6613,6 @@ PHP_FUNCTION(openssl_verify)
66136613
66146614 PHP_OPENSSL_CHECK_SIZE_T_TO_UINT (signature_len , signature , 2 );
66156615
6616- pkey = php_openssl_pkey_from_zval (key , 1 , NULL , 0 , & free_pkey );
6617- if (pkey == NULL ) {
6618- if (!EG (exception )) {
6619- zend_argument_type_error (3 , "cannot be coerced into a public key" );
6620- }
6621- RETURN_THROWS ();
6622- }
6623-
6624-
66256616 if (method == NULL || Z_TYPE_P (method ) == IS_LONG ) {
66266617 if (method != NULL ) {
66276618 signature_algo = Z_LVAL_P (method );
@@ -6635,8 +6626,16 @@ PHP_FUNCTION(openssl_verify)
66356626 RETURN_THROWS ();
66366627 }
66376628 if (!mdtype ) {
6638- zend_argument_value_error (4 , "must be a valid signature algorithm" );
6639- RETURN_THROWS ();
6629+ php_error_docref (NULL , E_WARNING , "Unknown signature algorithm" );
6630+ RETURN_FALSE ;
6631+ }
6632+
6633+ pkey = php_openssl_pkey_from_zval (key , 1 , NULL , 0 , & free_pkey );
6634+ if (pkey == NULL ) {
6635+ if (!EG (exception )) {
6636+ php_error_docref (NULL , E_WARNING , "Supplied key param cannot be coerced into a public key" );
6637+ }
6638+ RETURN_FALSE ;
66406639 }
66416640
66426641 md_ctx = EVP_MD_CTX_create ();
@@ -6688,8 +6687,8 @@ PHP_FUNCTION(openssl_seal)
66886687 if (method ) {
66896688 cipher = EVP_get_cipherbyname (method );
66906689 if (!cipher ) {
6691- zend_argument_value_error ( 5 , "must be a valid signature algorithm" );
6692- RETURN_THROWS () ;
6690+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
6691+ RETURN_FALSE ;
66936692 }
66946693 } else {
66956694 cipher = EVP_rc4 ();
@@ -6816,16 +6815,16 @@ PHP_FUNCTION(openssl_open)
68166815 pkey = php_openssl_pkey_from_zval (privkey , 0 , "" , 0 , & free_pkey );
68176816 if (pkey == NULL ) {
68186817 if (!EG (exception )) {
6819- zend_argument_type_error ( 4 , "cannot coerce into a private key" );
6818+ php_error_docref ( NULL , E_WARNING , "Unable to coerce parameter 4 into a private key" );
68206819 }
6821- RETURN_THROWS () ;
6820+ RETURN_FALSE ;
68226821 }
68236822
68246823 if (method ) {
68256824 cipher = EVP_get_cipherbyname (method );
68266825 if (!cipher ) {
6827- zend_argument_value_error ( 5 , "must be a valid signature algorithm" );
6828- RETURN_THROWS () ;
6826+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
6827+ RETURN_FALSE ;
68296828 }
68306829 } else {
68316830 cipher = EVP_rc4 ();
@@ -6958,8 +6957,8 @@ PHP_FUNCTION(openssl_digest)
69586957 }
69596958 mdtype = EVP_get_digestbyname (method );
69606959 if (!mdtype ) {
6961- zend_argument_value_error ( 2 , "must be a valid signature algorithm" );
6962- RETURN_THROWS () ;
6960+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
6961+ RETURN_FALSE ;
69636962 }
69646963
69656964 siglen = EVP_MD_size (mdtype );
@@ -7218,7 +7217,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
72187217
72197218 cipher_type = EVP_get_cipherbyname (method );
72207219 if (!cipher_type ) {
7221- zend_value_error ( "Unknown cipher algorithm" );
7220+ php_error_docref ( NULL , E_WARNING , "Unknown cipher algorithm" );
72227221 return NULL ;
72237222 }
72247223
@@ -7334,7 +7333,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
73347333
73357334 cipher_type = EVP_get_cipherbyname (method );
73367335 if (!cipher_type ) {
7337- zend_value_error ( "Unknown cipher algorithm" );
7336+ php_error_docref ( NULL , E_WARNING , "Unknown cipher algorithm" );
73387337 return NULL ;
73397338 }
73407339
@@ -7420,6 +7419,7 @@ PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
74207419
74217420 cipher_type = EVP_get_cipherbyname (method );
74227421 if (!cipher_type ) {
7422+ php_error_docref (NULL , E_WARNING , "Unknown cipher algorithm" );
74237423 return -1 ;
74247424 }
74257425
@@ -7442,9 +7442,9 @@ PHP_FUNCTION(openssl_cipher_iv_length)
74427442 RETURN_THROWS ();
74437443 }
74447444
7445+ /* Warning is emitted in php_openssl_cipher_iv_length */
74457446 if ((ret = php_openssl_cipher_iv_length (method )) == -1 ) {
7446- zend_argument_value_error (1 , "must be a valid cipher algorithm" );
7447- RETURN_THROWS ();
7447+ RETURN_FALSE ;
74487448 }
74497449
74507450 RETURN_LONG (ret );
0 commit comments