@@ -45,7 +45,6 @@ PHP_MINIT_FUNCTION(password) /* {{{ */
45
45
REGISTER_LONG_CONSTANT ("PASSWORD_BCRYPT" , PHP_PASSWORD_BCRYPT , CONST_CS | CONST_PERSISTENT );
46
46
#if HAVE_ARGON2LIB
47
47
REGISTER_LONG_CONSTANT ("PASSWORD_ARGON2I" , PHP_PASSWORD_ARGON2I , CONST_CS | CONST_PERSISTENT );
48
- REGISTER_LONG_CONSTANT ("PASSWORD_ARGON2" , PHP_PASSWORD_ARGON2 , CONST_CS | CONST_PERSISTENT );
49
48
#endif
50
49
51
50
REGISTER_LONG_CONSTANT ("PASSWORD_BCRYPT_DEFAULT_COST" , PHP_PASSWORD_BCRYPT_COST , CONST_CS | CONST_PERSISTENT );
@@ -195,13 +194,13 @@ PHP_FUNCTION(password_get_info)
195
194
case PHP_PASSWORD_ARGON2I :
196
195
{
197
196
zend_long v = 0 ;
198
- zend_long m_cost = PHP_PASSWORD_ARGON2_MEMORY_COST ;
199
- zend_long t_cost = PHP_PASSWORD_ARGON2_TIME_COST ;
197
+ zend_long memory_cost = PHP_PASSWORD_ARGON2_MEMORY_COST ;
198
+ zend_long time_cost = PHP_PASSWORD_ARGON2_TIME_COST ;
200
199
zend_long threads = PHP_PASSWORD_ARGON2_THREADS ;
201
200
202
- sscanf (hash , "$%*[argon2i]$v=" ZEND_LONG_FMT "$m=" ZEND_LONG_FMT ",t=" ZEND_LONG_FMT ",p=" ZEND_LONG_FMT , & v , & m_cost , & t_cost , & threads );
203
- add_assoc_long (& options , "m_cost " , m_cost );
204
- add_assoc_long (& options , "t_cost " , t_cost );
201
+ sscanf (hash , "$%*[argon2i]$v=" ZEND_LONG_FMT "$m=" ZEND_LONG_FMT ",t=" ZEND_LONG_FMT ",p=" ZEND_LONG_FMT , & v , & memory_cost , & time_cost , & threads );
202
+ add_assoc_long (& options , "memory_cost " , memory_cost );
203
+ add_assoc_long (& options , "time_cost " , time_cost );
205
204
add_assoc_long (& options , "threads" , threads );
206
205
}
207
206
break ;
@@ -259,25 +258,25 @@ PHP_FUNCTION(password_needs_rehash)
259
258
case PHP_PASSWORD_ARGON2I :
260
259
{
261
260
zend_long v = 0 ;
262
- zend_long new_m_cost = PHP_PASSWORD_ARGON2_MEMORY_COST , m_cost = 0 ;
263
- zend_long new_t_cost = PHP_PASSWORD_ARGON2_TIME_COST , t_cost = 0 ;
261
+ zend_long new_memory_cost = PHP_PASSWORD_ARGON2_MEMORY_COST , memory_cost = 0 ;
262
+ zend_long new_time_cost = PHP_PASSWORD_ARGON2_TIME_COST , time_cost = 0 ;
264
263
zend_long new_threads = PHP_PASSWORD_ARGON2_THREADS , threads = 0 ;
265
264
266
- if (options && (option_buffer = zend_hash_str_find (options , "m_cost " , sizeof ("m_cost " )- 1 )) != NULL ) {
267
- new_m_cost = zval_get_long (option_buffer );
265
+ if (options && (option_buffer = zend_hash_str_find (options , "memory_cost " , sizeof ("memory_cost " )- 1 )) != NULL ) {
266
+ new_memory_cost = zval_get_long (option_buffer );
268
267
}
269
268
270
- if (options && (option_buffer = zend_hash_str_find (options , "t_cost " , sizeof ("t_cost " )- 1 )) != NULL ) {
271
- new_t_cost = zval_get_long (option_buffer );
269
+ if (options && (option_buffer = zend_hash_str_find (options , "time_cost " , sizeof ("time_cost " )- 1 )) != NULL ) {
270
+ new_time_cost = zval_get_long (option_buffer );
272
271
}
273
272
274
273
if (options && (option_buffer = zend_hash_str_find (options , "threads" , sizeof ("threads" )- 1 )) != NULL ) {
275
274
new_threads = zval_get_long (option_buffer );
276
275
}
277
276
278
- sscanf (hash , "$%*[argon2i]$v=" ZEND_LONG_FMT "$m=" ZEND_LONG_FMT ",t=" ZEND_LONG_FMT ",p=" ZEND_LONG_FMT , & v , & m_cost , & t_cost , & threads );
277
+ sscanf (hash , "$%*[argon2i]$v=" ZEND_LONG_FMT "$m=" ZEND_LONG_FMT ",t=" ZEND_LONG_FMT ",p=" ZEND_LONG_FMT , & v , & memory_cost , & time_cost , & threads );
279
278
280
- if (new_t_cost != t_cost || new_m_cost != m_cost || new_threads != threads ) {
279
+ if (new_time_cost != time_cost || new_memory_cost != memory_cost || new_threads != threads ) {
281
280
RETURN_TRUE ;
282
281
}
283
282
}
@@ -367,8 +366,8 @@ PHP_FUNCTION(password_hash)
367
366
zval * option_buffer ;
368
367
369
368
#if HAVE_ARGON2LIB
370
- size_t t_cost = PHP_PASSWORD_ARGON2_TIME_COST ;
371
- size_t m_cost = PHP_PASSWORD_ARGON2_MEMORY_COST ;
369
+ size_t time_cost = PHP_PASSWORD_ARGON2_TIME_COST ;
370
+ size_t memory_cost = PHP_PASSWORD_ARGON2_MEMORY_COST ;
372
371
size_t threads = PHP_PASSWORD_ARGON2_THREADS ;
373
372
argon2_type type = Argon2_i ;
374
373
#endif
@@ -399,21 +398,21 @@ PHP_FUNCTION(password_hash)
399
398
#if HAVE_ARGON2LIB
400
399
case PHP_PASSWORD_ARGON2I :
401
400
{
402
- if (options && (option_buffer = zend_hash_str_find (options , "m_cost " , sizeof ("m_cost " )- 1 )) != NULL ) {
403
- m_cost = zval_get_long (option_buffer );
401
+ if (options && (option_buffer = zend_hash_str_find (options , "memory_cost " , sizeof ("memory_cost " )- 1 )) != NULL ) {
402
+ memory_cost = zval_get_long (option_buffer );
404
403
}
405
404
406
- if (m_cost > ARGON2_MAX_MEMORY || m_cost < ARGON2_MIN_MEMORY ) {
407
- php_error_docref (NULL , E_WARNING , "Memory cost is outside of allowed memory range" , m_cost );
405
+ if (memory_cost > ARGON2_MAX_MEMORY || memory_cost < ARGON2_MIN_MEMORY ) {
406
+ php_error_docref (NULL , E_WARNING , "Memory cost is outside of allowed memory range" , memory_cost );
408
407
RETURN_NULL ();
409
408
}
410
409
411
- if (options && (option_buffer = zend_hash_str_find (options , "t_cost " , sizeof ("t_cost " )- 1 )) != NULL ) {
412
- t_cost = zval_get_long (option_buffer );
410
+ if (options && (option_buffer = zend_hash_str_find (options , "time_cost " , sizeof ("time_cost " )- 1 )) != NULL ) {
411
+ time_cost = zval_get_long (option_buffer );
413
412
}
414
413
415
- if (t_cost > ARGON2_MAX_TIME || t_cost < ARGON2_MIN_TIME ) {
416
- php_error_docref (NULL , E_WARNING , "Time cost is outside of allowed time range" , t_cost );
414
+ if (time_cost > ARGON2_MAX_TIME || time_cost < ARGON2_MIN_TIME ) {
415
+ php_error_docref (NULL , E_WARNING , "Time cost is outside of allowed time range" , time_cost );
417
416
RETURN_NULL ();
418
417
}
419
418
@@ -532,8 +531,8 @@ PHP_FUNCTION(password_hash)
532
531
int status = 0 ;
533
532
534
533
encoded_len = argon2_encodedlen (
535
- t_cost ,
536
- m_cost ,
534
+ time_cost ,
535
+ memory_cost ,
537
536
threads ,
538
537
(uint32_t )salt_len ,
539
538
out_len
@@ -543,8 +542,8 @@ PHP_FUNCTION(password_hash)
543
542
zend_string * encoded = zend_string_alloc (encoded_len , 0 );
544
543
545
544
status = argon2_hash (
546
- t_cost ,
547
- m_cost ,
545
+ time_cost ,
546
+ memory_cost ,
548
547
threads ,
549
548
password ,
550
549
password_len ,
0 commit comments