Lines Matching refs:ops
85 php_hash_ops *ops; in php_hash_fetch_ops() local
89 if (SUCCESS != zend_hash_find(&php_hash_hashtable, lower, algo_len + 1, (void*)&ops)) { in php_hash_fetch_ops()
90 ops = NULL; in php_hash_fetch_ops()
94 return ops; in php_hash_fetch_ops()
98 PHP_HASH_API void php_hash_register_algo(const char *algo, const php_hash_ops *ops) /* {{{ */ in php_hash_register_algo() argument
104 zend_hash_add(&php_hash_hashtable, lower, algo_len + 1, (void*)ops, sizeof(php_hash_ops), NULL); in php_hash_register_algo()
109 PHP_HASH_API int php_hash_copy(const void *ops, void *orig_context, void *dest_context) /* {{{ */ in php_hash_copy() argument
111 php_hash_ops *hash_ops = (php_hash_ops *)ops; in php_hash_copy()
125 const php_hash_ops *ops; in php_hash_do_hash() local
133 ops = php_hash_fetch_ops(algo, algo_len); in php_hash_do_hash()
134 if (!ops) { in php_hash_do_hash()
146 context = emalloc(ops->context_size); in php_hash_do_hash()
147 ops->hash_init(context); in php_hash_do_hash()
154 ops->hash_update(context, (unsigned char *) buf, n); in php_hash_do_hash()
158 ops->hash_update(context, (unsigned char *) data, data_len); in php_hash_do_hash()
161 digest = emalloc(ops->digest_size + 1); in php_hash_do_hash()
162 ops->hash_final((unsigned char *) digest, context); in php_hash_do_hash()
166 digest[ops->digest_size] = 0; in php_hash_do_hash()
167 RETURN_STRINGL(digest, ops->digest_size, 0); in php_hash_do_hash()
169 char *hex_digest = safe_emalloc(ops->digest_size, 2, 1); in php_hash_do_hash()
171 php_hash_bin2hex(hex_digest, (unsigned char *) digest, ops->digest_size); in php_hash_do_hash()
172 hex_digest[2 * ops->digest_size] = 0; in php_hash_do_hash()
174 RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0); in php_hash_do_hash()
202 const php_hash_ops *ops; in php_hash_do_hash_hmac() local
211 ops = php_hash_fetch_ops(algo, algo_len); in php_hash_do_hash_hmac()
212 if (!ops) { in php_hash_do_hash_hmac()
224 context = emalloc(ops->context_size); in php_hash_do_hash_hmac()
225 ops->hash_init(context); in php_hash_do_hash_hmac()
227 K = emalloc(ops->block_size); in php_hash_do_hash_hmac()
228 memset(K, 0, ops->block_size); in php_hash_do_hash_hmac()
230 if (key_len > ops->block_size) { in php_hash_do_hash_hmac()
232 ops->hash_update(context, (unsigned char *) key, key_len); in php_hash_do_hash_hmac()
233 ops->hash_final((unsigned char *) K, context); in php_hash_do_hash_hmac()
235 ops->hash_init(context); in php_hash_do_hash_hmac()
241 for(i=0; i < ops->block_size; i++) { in php_hash_do_hash_hmac()
244 ops->hash_update(context, (unsigned char *) K, ops->block_size); in php_hash_do_hash_hmac()
251 ops->hash_update(context, (unsigned char *) buf, n); in php_hash_do_hash_hmac()
255 ops->hash_update(context, (unsigned char *) data, data_len); in php_hash_do_hash_hmac()
258 digest = emalloc(ops->digest_size + 1); in php_hash_do_hash_hmac()
259 ops->hash_final((unsigned char *) digest, context); in php_hash_do_hash_hmac()
262 for(i=0; i < ops->block_size; i++) { in php_hash_do_hash_hmac()
267 ops->hash_init(context); in php_hash_do_hash_hmac()
268 ops->hash_update(context, (unsigned char *) K, ops->block_size); in php_hash_do_hash_hmac()
269 ops->hash_update(context, (unsigned char *) digest, ops->digest_size); in php_hash_do_hash_hmac()
270 ops->hash_final((unsigned char *) digest, context); in php_hash_do_hash_hmac()
273 memset(K, 0, ops->block_size); in php_hash_do_hash_hmac()
278 digest[ops->digest_size] = 0; in php_hash_do_hash_hmac()
279 RETURN_STRINGL(digest, ops->digest_size, 0); in php_hash_do_hash_hmac()
281 char *hex_digest = safe_emalloc(ops->digest_size, 2, 1); in php_hash_do_hash_hmac()
283 php_hash_bin2hex(hex_digest, (unsigned char *) digest, ops->digest_size); in php_hash_do_hash_hmac()
284 hex_digest[2 * ops->digest_size] = 0; in php_hash_do_hash_hmac()
286 RETURN_STRINGL(hex_digest, 2 * ops->digest_size, 0); in php_hash_do_hash_hmac()
318 const php_hash_ops *ops; in PHP_FUNCTION() local
325 ops = php_hash_fetch_ops(algo, algo_len); in PHP_FUNCTION()
326 if (!ops) { in PHP_FUNCTION()
338 context = emalloc(ops->context_size); in PHP_FUNCTION()
339 ops->hash_init(context); in PHP_FUNCTION()
342 hash->ops = ops; in PHP_FUNCTION()
348 char *K = emalloc(ops->block_size); in PHP_FUNCTION()
351 memset(K, 0, ops->block_size); in PHP_FUNCTION()
353 if (key_len > ops->block_size) { in PHP_FUNCTION()
355 ops->hash_update(context, (unsigned char *) key, key_len); in PHP_FUNCTION()
356 ops->hash_final((unsigned char *) K, context); in PHP_FUNCTION()
358 ops->hash_init(context); in PHP_FUNCTION()
364 for(i=0; i < ops->block_size; i++) { in PHP_FUNCTION()
367 ops->hash_update(context, (unsigned char *) K, ops->block_size); in PHP_FUNCTION()
390 hash->ops->hash_update(hash->context, (unsigned char *) data, data_len); in PHP_FUNCTION()
424 hash->ops->hash_update(hash->context, (unsigned char *) buf, n); in PHP_FUNCTION()
458 hash->ops->hash_update(hash->context, (unsigned char *) buf, n); in PHP_FUNCTION()
483 digest_len = hash->ops->digest_size; in PHP_FUNCTION()
485 hash->ops->hash_final((unsigned char *) digest, hash->context); in PHP_FUNCTION()
490 for(i=0; i < hash->ops->block_size; i++) { in PHP_FUNCTION()
495 hash->ops->hash_init(hash->context); in PHP_FUNCTION()
496 hash->ops->hash_update(hash->context, (unsigned char *) hash->key, hash->ops->block_size); in PHP_FUNCTION()
497 hash->ops->hash_update(hash->context, (unsigned char *) digest, hash->ops->digest_size); in PHP_FUNCTION()
498 hash->ops->hash_final((unsigned char *) digest, hash->context); in PHP_FUNCTION()
501 memset(hash->key, 0, hash->ops->block_size); in PHP_FUNCTION()
546 context = emalloc(hash->ops->context_size); in PHP_FUNCTION()
547 hash->ops->hash_init(context); in PHP_FUNCTION()
549 res = hash->ops->hash_copy(hash->ops, hash->context, context); in PHP_FUNCTION()
556 copy_hash->ops = hash->ops; in PHP_FUNCTION()
559 copy_hash->key = ecalloc(1, hash->ops->block_size); in PHP_FUNCTION()
561 memcpy(copy_hash->key, hash->key, hash->ops->block_size); in PHP_FUNCTION()
594 unsigned char *dummy = emalloc(hash->ops->digest_size); in php_hash_dtor()
595 hash->ops->hash_final(dummy, hash->context); in php_hash_dtor()
601 memset(hash->key, 0, hash->ops->block_size); in php_hash_dtor()
729 …const php_hash_ops *ops = php_hash_fetch_ops(algorithm_lookup.hash_name, strlen(algorithm_lookup.h… in PHP_FUNCTION() local
730 if (ops) { in PHP_FUNCTION()
731 RETVAL_LONG(ops->digest_size); in PHP_FUNCTION()
772 …const php_hash_ops *ops = php_hash_fetch_ops(algorithm_lookup.hash_name, strlen(algorithm_lookup.h… in PHP_FUNCTION() local
773 if (ops) { in PHP_FUNCTION()
778 int block_size = ops->digest_size; in PHP_FUNCTION()
782 context = emalloc(ops->context_size); in PHP_FUNCTION()
783 ops->hash_init(context); in PHP_FUNCTION()
786 digest = emalloc(ops->digest_size + 1); in PHP_FUNCTION()
789 ops->hash_init(context); in PHP_FUNCTION()
792 ops->hash_update(context, &null, 1); in PHP_FUNCTION()
794 ops->hash_update(context, (unsigned char *)padded_salt, salt_len); in PHP_FUNCTION()
795 ops->hash_update(context, (unsigned char *)password, password_len); in PHP_FUNCTION()
796 ops->hash_final((unsigned char *)digest, context); in PHP_FUNCTION()