@@ -329,40 +329,42 @@ PHP_FUNCTION(hash_hmac_file)
329
329
}
330
330
/* }}} */
331
331
332
- static void php_hashcontext_ctor (INTERNAL_FUNCTION_PARAMETERS , zval * objval ) {
332
+ /* {{{ proto HashContext hash_init(string algo[, int options, string key])
333
+ Initialize a hashing context */
334
+ PHP_FUNCTION (hash_init )
335
+ {
333
336
zend_string * algo , * key = NULL ;
334
337
zend_long options = 0 ;
335
338
int argc = ZEND_NUM_ARGS ();
336
339
void * context ;
337
340
const php_hash_ops * ops ;
338
- php_hashcontext_object * hash = php_hashcontext_from_object ( Z_OBJ_P ( objval )) ;
341
+ php_hashcontext_object * hash ;
339
342
340
343
if (zend_parse_parameters (argc , "S|lS" , & algo , & options , & key ) == FAILURE ) {
341
- zval_ptr_dtor (return_value );
342
344
RETURN_NULL ();
343
345
}
344
346
345
347
ops = php_hash_fetch_ops (ZSTR_VAL (algo ), ZSTR_LEN (algo ));
346
348
if (!ops ) {
347
349
php_error_docref (NULL , E_WARNING , "Unknown hashing algorithm: %s" , ZSTR_VAL (algo ));
348
- zval_ptr_dtor (return_value );
349
350
RETURN_FALSE ;
350
351
}
351
352
352
353
if (options & PHP_HASH_HMAC ) {
353
354
if (!ops -> is_crypto ) {
354
355
php_error_docref (NULL , E_WARNING , "HMAC requested with a non-cryptographic hashing algorithm: %s" , ZSTR_VAL (algo ));
355
- zval_ptr_dtor (return_value );
356
356
RETURN_FALSE ;
357
357
}
358
358
if (!key || (ZSTR_LEN (key ) == 0 )) {
359
359
/* Note: a zero length key is no key at all */
360
360
php_error_docref (NULL , E_WARNING , "HMAC requested without a key" );
361
- zval_ptr_dtor (return_value );
362
361
RETURN_FALSE ;
363
362
}
364
363
}
365
364
365
+ object_init_ex (return_value , php_hashcontext_ce );
366
+ hash = php_hashcontext_from_object (Z_OBJ_P (return_value ));
367
+
366
368
context = emalloc (ops -> context_size );
367
369
ops -> hash_init (context );
368
370
@@ -396,14 +398,6 @@ static void php_hashcontext_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *objval) {
396
398
hash -> key = (unsigned char * ) K ;
397
399
}
398
400
}
399
-
400
- /* {{{ proto HashContext hash_init(string algo[, int options, string key])
401
- Initialize a hashing context */
402
- PHP_FUNCTION (hash_init )
403
- {
404
- object_init_ex (return_value , php_hashcontext_ce );
405
- php_hashcontext_ctor (INTERNAL_FUNCTION_PARAM_PASSTHRU , return_value );
406
- }
407
401
/* }}} */
408
402
409
403
#define PHP_HASHCONTEXT_VERIFY (func , hash ) { \
0 commit comments