1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00

Remove password_make_salt() from the implementation

This commit is contained in:
Anthony Ferrara
2012-08-28 11:24:33 -04:00
parent 707c9073b5
commit e05413ca59
5 changed files with 0 additions and 118 deletions

View File

@@ -1884,10 +1884,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_password_verify, 0, 0, 2)
ZEND_ARG_INFO(0, password)
ZEND_ARG_INFO(0, hash)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_password_make_salt, 0, 0, 1)
ZEND_ARG_INFO(0, length)
ZEND_ARG_INFO(0, raw_output)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ proc_open.c */
#ifdef PHP_CAN_SUPPORT_PROC_OPEN
@@ -2907,8 +2903,6 @@ const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(password_get_info, arginfo_password_get_info)
PHP_FE(password_needs_rehash, arginfo_password_needs_rehash)
PHP_FE(password_verify, arginfo_password_verify)
PHP_FE(password_make_salt, arginfo_password_make_salt)
PHP_FE(convert_uuencode, arginfo_convert_uuencode)
PHP_FE(convert_uudecode, arginfo_convert_uudecode)

View File

@@ -40,9 +40,6 @@ PHP_MINIT_FUNCTION(password) /* {{{ */
REGISTER_LONG_CONSTANT("PASSWORD_DEFAULT", PHP_PASSWORD_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT", PHP_PASSWORD_BCRYPT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PASSWORD_SALT_RAW", PHP_PASSWORD_SALT_RAW, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PASSWORD_SALT_BCRYPT", PHP_PASSWORD_SALT_BCRYPT, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
@@ -95,8 +92,6 @@ static int php_password_salt_to64(const char *str, const int str_len, const int
}
/* }}} */
#define PHP_PASSWORD_FUNCTION_EXISTS(func, func_len) (zend_hash_find(EG(function_table), (func), (func_len) + 1, (void **) &func_ptr) == SUCCESS && func_ptr->type == ZEND_INTERNAL_FUNCTION && func_ptr->internal_function.handler != zif_display_disabled_function)
static int php_password_make_salt(long length, int salt_type, char *ret TSRMLS_DC) /* {{{ */
{
int buffer_valid = 0;
@@ -277,35 +272,6 @@ PHP_FUNCTION(password_verify)
}
/* }}} */
/* {{{ proto string password_make_salt(int length, int salt_type = PASSWORD_SALT_BCRYPT)
Make a new random salt */
PHP_FUNCTION(password_make_salt)
{
char *salt;
long length = 0, salt_type = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &length, &salt_type) == FAILURE) {
RETURN_NULL();
}
if (length <= 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length cannot be less than or equal zero: %ld", length);
RETURN_NULL();
} else if (length > (LONG_MAX / 3)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Length is too large to safely generate");
RETURN_NULL();
}
if (!salt_type) {
salt_type = PHP_PASSWORD_SALT_BCRYPT;
}
salt = safe_emalloc(length, 1, 1);
if (php_password_make_salt(length, (int) salt_type, salt TSRMLS_CC) == FAILURE) {
efree(salt);
RETURN_FALSE;
}
RETURN_STRINGL(salt, length, 0);
}
/* }}} */
/* {{{ proto string password_hash(string password, int algo, array options = array())
Hash a password */
PHP_FUNCTION(password_hash)

View File

@@ -23,7 +23,6 @@
PHP_FUNCTION(password_hash);
PHP_FUNCTION(password_verify);
PHP_FUNCTION(password_make_salt);
PHP_FUNCTION(password_needs_rehash);
PHP_FUNCTION(password_get_info);

View File

@@ -1,40 +0,0 @@
--TEST--
Test normal operation of password_make_salt()
--FILE--
<?php
//-=-=-=-
echo strlen(password_make_salt(1)) . "\n";
echo strlen(password_make_salt(2)) . "\n";
echo strlen(password_make_salt(3)) . "\n";
echo strlen(password_make_salt(4)) . "\n";
echo strlen(password_make_salt(5, PASSWORD_SALT_BCRYPT)) . "\n";
echo "\n";
echo strlen(password_make_salt(1, PASSWORD_SALT_RAW)) . "\n";
echo strlen(password_make_salt(2, PASSWORD_SALT_RAW)) . "\n";
echo strlen(password_make_salt(3, PASSWORD_SALT_RAW)) . "\n";
echo strlen(password_make_salt(4, PASSWORD_SALT_RAW)) . "\n";
echo strlen(password_make_salt(5, PASSWORD_SALT_RAW)) . "\n";
echo "\n";
$a = password_make_salt(32);
$b = password_make_salt(32);
var_dump($a != $b);
echo "OK!";
?>
--EXPECT--
1
2
3
4
5
1
2
3
4
5
bool(true)
OK!

View File

@@ -1,37 +0,0 @@
--TEST--
Test error operation of password_make_salt()
--FILE--
<?php
//-=-=-=-
var_dump(password_make_salt());
var_dump(password_make_salt("foo"));
var_dump(password_make_salt(-1));
var_dump(password_make_salt(PHP_INT_MAX));
var_dump(password_make_salt(floor(PHP_INT_MAX / 2.9)));
var_dump(password_make_salt(5, 999));
?>
--EXPECTF--
Warning: password_make_salt() expects at least 1 parameter, 0 given in %s on line %d
NULL
Warning: password_make_salt() expects parameter 1 to be long, string given in %s on line %d
NULL
Warning: password_make_salt(): Length cannot be less than or equal zero: -1 in %s on line %d
NULL
Warning: password_make_salt(): Length is too large to safely generate in %s on line %d
NULL
Warning: password_make_salt(): Length is too large to safely generate in %s on line %d
NULL
Warning: password_make_salt(): Unknown salt type paramter in %s on line %d
bool(false)