com php-src: Implement password_verify: ext/standard/pass word.c

From: Date: Mon, 25 Jun 2012 03:35:26 +0000
Subject: com php-src: Implement password_verify: ext/standard/pass word.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-70392@lists.php.net to get a copy of this message
Commit: 657402832b7884f52bf07b2e6f704510395fd413 Author: Anthony Ferrara <ircmaxell@ircmaxell.com> Sun, 24 Jun 2012 23:35:26 -0400 Parents: 7e41980fe4972e097e178c034f92920c9c63086c Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=657402832b7884f52bf07b2e6f704510395fd413 Log: Implement password_verify Changed paths: M ext/standard/password.c Diff: diff --git a/ext/standard/password.c b/ext/standard/password.c index 9201ff3..665e69f 100644 --- a/ext/standard/password.c +++ b/ext/standard/password.c @@ -112,6 +112,33 @@ static int php_password_make_salt(int length, int raw, char *ret) PHP_FUNCTION(password_verify) { + zval *password, *hash, *ret; + int status = 0, i; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &password, &hash) == FAILURE) { + RETURN_FALSE; + } + + zend_call_method_with_2_params(NULL, NULL, NULL, "crypt", &ret, password, hash); + + if (Z_TYPE_P(ret) != IS_STRING) { + zval_ptr_dtor(&ret); + RETURN_FALSE; + } + + if (Z_STRLEN_P(ret) != Z_STRLEN_P(hash)) { + zval_ptr_dtor(&ret); + RETURN_FALSE; + } + + for (i = 0; i < Z_STRLEN_P(ret); i++) { + status |= (Z_STRVAL_P(ret)[i] ^ Z_STRVAL_P(hash)[i]); + } + + zval_ptr_dtor(&ret); + + RETURN_BOOL(status == 0); + } PHP_FUNCTION(password_make_salt)

« previous php.cvs (#70392) next »