diff options
| author | Ben Fuhrmannek | 2021-11-19 14:57:01 +0100 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-11-19 14:57:01 +0100 |
| commit | c447df6ce8964b2863a50f0f8027d9b234b7507f (patch) | |
| tree | f3a6633d09f628bcd4efd409d92c8b44efe07868 /src/sp_php_compat.h | |
| parent | a34055a8fb6aa421a13da698ea0fe514bb27952e (diff) | |
replaced call_user_func with C level call
Diffstat (limited to 'src/sp_php_compat.h')
| -rw-r--r-- | src/sp_php_compat.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h index 09d9a1f..d1102a8 100644 --- a/src/sp_php_compat.h +++ b/src/sp_php_compat.h | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | /* code in this file is licensed under its original license | ||
| 2 | The PHP License, version 3.01 (https://www.php.net/license/3_01.txt) | ||
| 3 | which is also included with these sources in the file `PHP_LICENSE` */ | ||
| 4 | |||
| 1 | #if PHP_VERSION_ID < 80000 | 5 | #if PHP_VERSION_ID < 80000 |
| 2 | 6 | ||
| 3 | // copied from PHP 8.0.9 sources | 7 | // copied from PHP 8.0.9 sources |
| @@ -93,4 +97,34 @@ static zend_always_inline void zend_string_efree(zend_string *s) | |||
| 93 | __ht->nNumUsed = _idx; \ | 97 | __ht->nNumUsed = _idx; \ |
| 94 | } while (0) | 98 | } while (0) |
| 95 | 99 | ||
| 96 | #endif \ No newline at end of file | 100 | #endif |
| 101 | |||
| 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c | ||
| 103 | |||
| 104 | static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const size_t length) { | ||
| 105 | size_t i; | ||
| 106 | for (i=0; i < length; i++) { | ||
| 107 | out[i] = in[i] ^ xor_with; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | |||
| 111 | static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const size_t key_len) { | ||
| 112 | memset(K, 0, ops->block_size); | ||
| 113 | if (key_len > ops->block_size) { | ||
| 114 | /* Reduce the key first */ | ||
| 115 | ops->hash_init(context); | ||
| 116 | ops->hash_update(context, key, key_len); | ||
| 117 | ops->hash_final(K, context); | ||
| 118 | } else { | ||
| 119 | memcpy(K, key, key_len); | ||
| 120 | } | ||
| 121 | /* XOR the key with 0x36 to get the ipad) */ | ||
| 122 | php_hash_string_xor_char(K, K, 0x36, ops->block_size); | ||
| 123 | } | ||
| 124 | |||
| 125 | static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const zend_long data_size) { | ||
| 126 | ops->hash_init(context); | ||
| 127 | ops->hash_update(context, key, ops->block_size); | ||
| 128 | ops->hash_update(context, data, data_size); | ||
| 129 | ops->hash_final(final, context); | ||
| 130 | } | ||
