@@ -1553,12 +1553,6 @@ PHP_FUNCTION(openssl_spki_new)
1553
1553
1554
1554
PHP_OPENSSL_CHECK_SIZE_T_TO_INT (challenge_len , challenge , 2 );
1555
1555
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
-
1562
1556
pkey = php_openssl_pkey_from_zval (zpkey , 0 , challenge , challenge_len , & free_pkey );
1563
1557
if (pkey == NULL ) {
1564
1558
if (!EG (exception )) {
@@ -1567,6 +1561,13 @@ PHP_FUNCTION(openssl_spki_new)
1567
1561
goto cleanup ;
1568
1562
}
1569
1563
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
+
1570
1571
if ((spki = NETSCAPE_SPKI_new ()) == NULL ) {
1571
1572
php_openssl_store_errors ();
1572
1573
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
1851
1852
zend_string * ret ;
1852
1853
1853
1854
if (!(mdtype = EVP_get_digestbyname (method ))) {
1854
- zend_value_error ( "Unknown signature algorithm" );
1855
+ php_error_docref ( NULL , E_WARNING , "Unknown signature algorithm" );
1855
1856
return NULL ;
1856
1857
} else if (!X509_digest (peer , mdtype , md , & n )) {
1857
1858
php_openssl_store_errors ();
@@ -3820,7 +3821,7 @@ static EVP_PKEY * php_openssl_generate_private_key(struct php_x509_request * req
3820
3821
break ;
3821
3822
#endif
3822
3823
default :
3823
- zend_value_error ( "Unsupported private key type" );
3824
+ php_error_docref ( NULL , E_WARNING , "Unsupported private key type" );
3824
3825
}
3825
3826
} else {
3826
3827
php_openssl_store_errors ();
@@ -4212,7 +4213,7 @@ PHP_FUNCTION(openssl_pkey_new)
4212
4213
}
4213
4214
4214
4215
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" );
4216
4217
goto clean_exit ;
4217
4218
}
4218
4219
@@ -4342,10 +4343,9 @@ PHP_FUNCTION(openssl_pkey_export_to_file)
4342
4343
key = php_openssl_pkey_from_zval (zpkey , 0 , passphrase , passphrase_len , & free_pkey );
4343
4344
if (key == NULL ) {
4344
4345
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" );
4347
4347
}
4348
- RETURN_THROWS () ;
4348
+ RETURN_FALSE ;
4349
4349
}
4350
4350
4351
4351
if (php_openssl_open_base_dir_chk (filename )) {
@@ -4429,9 +4429,9 @@ PHP_FUNCTION(openssl_pkey_export)
4429
4429
key = php_openssl_pkey_from_zval (zpkey , 0 , passphrase , passphrase_len , & free_pkey );
4430
4430
if (key == NULL ) {
4431
4431
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 " );
4433
4433
}
4434
- RETURN_THROWS () ;
4434
+ RETURN_FALSE ;
4435
4435
}
4436
4436
4437
4437
PHP_SSL_REQ_INIT (& req );
@@ -4859,8 +4859,8 @@ PHP_FUNCTION(openssl_pbkdf2)
4859
4859
}
4860
4860
4861
4861
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 ;
4864
4864
}
4865
4865
4866
4866
out_buffer = zend_string_alloc (key_length , 0 );
@@ -6545,9 +6545,9 @@ PHP_FUNCTION(openssl_sign)
6545
6545
pkey = php_openssl_pkey_from_zval (key , 0 , "" , 0 , & free_pkey );
6546
6546
if (pkey == NULL ) {
6547
6547
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" );
6549
6549
}
6550
- RETURN_THROWS () ;
6550
+ RETURN_FALSE ;
6551
6551
}
6552
6552
6553
6553
if (method == NULL || Z_TYPE_P (method ) == IS_LONG ) {
@@ -6563,8 +6563,8 @@ PHP_FUNCTION(openssl_sign)
6563
6563
RETURN_THROWS ();
6564
6564
}
6565
6565
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 ;
6568
6568
}
6569
6569
6570
6570
siglen = EVP_PKEY_size (pkey );
@@ -6613,15 +6613,6 @@ PHP_FUNCTION(openssl_verify)
6613
6613
6614
6614
PHP_OPENSSL_CHECK_SIZE_T_TO_UINT (signature_len , signature , 2 );
6615
6615
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
-
6625
6616
if (method == NULL || Z_TYPE_P (method ) == IS_LONG ) {
6626
6617
if (method != NULL ) {
6627
6618
signature_algo = Z_LVAL_P (method );
@@ -6635,8 +6626,16 @@ PHP_FUNCTION(openssl_verify)
6635
6626
RETURN_THROWS ();
6636
6627
}
6637
6628
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 ;
6640
6639
}
6641
6640
6642
6641
md_ctx = EVP_MD_CTX_create ();
@@ -6688,8 +6687,8 @@ PHP_FUNCTION(openssl_seal)
6688
6687
if (method ) {
6689
6688
cipher = EVP_get_cipherbyname (method );
6690
6689
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 ;
6693
6692
}
6694
6693
} else {
6695
6694
cipher = EVP_rc4 ();
@@ -6816,16 +6815,16 @@ PHP_FUNCTION(openssl_open)
6816
6815
pkey = php_openssl_pkey_from_zval (privkey , 0 , "" , 0 , & free_pkey );
6817
6816
if (pkey == NULL ) {
6818
6817
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" );
6820
6819
}
6821
- RETURN_THROWS () ;
6820
+ RETURN_FALSE ;
6822
6821
}
6823
6822
6824
6823
if (method ) {
6825
6824
cipher = EVP_get_cipherbyname (method );
6826
6825
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 ;
6829
6828
}
6830
6829
} else {
6831
6830
cipher = EVP_rc4 ();
@@ -6958,8 +6957,8 @@ PHP_FUNCTION(openssl_digest)
6958
6957
}
6959
6958
mdtype = EVP_get_digestbyname (method );
6960
6959
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 ;
6963
6962
}
6964
6963
6965
6964
siglen = EVP_MD_size (mdtype );
@@ -7218,7 +7217,7 @@ PHP_OPENSSL_API zend_string* php_openssl_encrypt(
7218
7217
7219
7218
cipher_type = EVP_get_cipherbyname (method );
7220
7219
if (!cipher_type ) {
7221
- zend_value_error ( "Unknown cipher algorithm" );
7220
+ php_error_docref ( NULL , E_WARNING , "Unknown cipher algorithm" );
7222
7221
return NULL ;
7223
7222
}
7224
7223
@@ -7334,7 +7333,7 @@ PHP_OPENSSL_API zend_string* php_openssl_decrypt(
7334
7333
7335
7334
cipher_type = EVP_get_cipherbyname (method );
7336
7335
if (!cipher_type ) {
7337
- zend_value_error ( "Unknown cipher algorithm" );
7336
+ php_error_docref ( NULL , E_WARNING , "Unknown cipher algorithm" );
7338
7337
return NULL ;
7339
7338
}
7340
7339
@@ -7420,6 +7419,7 @@ PHP_OPENSSL_API zend_long php_openssl_cipher_iv_length(const char *method)
7420
7419
7421
7420
cipher_type = EVP_get_cipherbyname (method );
7422
7421
if (!cipher_type ) {
7422
+ php_error_docref (NULL , E_WARNING , "Unknown cipher algorithm" );
7423
7423
return -1 ;
7424
7424
}
7425
7425
@@ -7442,9 +7442,9 @@ PHP_FUNCTION(openssl_cipher_iv_length)
7442
7442
RETURN_THROWS ();
7443
7443
}
7444
7444
7445
+ /* Warning is emitted in php_openssl_cipher_iv_length */
7445
7446
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 ;
7448
7448
}
7449
7449
7450
7450
RETURN_LONG (ret );
0 commit comments