diff options
Diffstat (limited to 'src/sp_php_compat.h')
| -rw-r--r-- | src/sp_php_compat.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h index d1102a8..04914b4 100644 --- a/src/sp_php_compat.h +++ b/src/sp_php_compat.h | |||
| @@ -100,6 +100,7 @@ static zend_always_inline void zend_string_efree(zend_string *s) | |||
| 100 | #endif | 100 | #endif |
| 101 | 101 | ||
| 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c | 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c |
| 103 | // slightly modified for PHP 8.1 compatibility | ||
| 103 | 104 | ||
| 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 | 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 | size_t i; |
| @@ -112,7 +113,11 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops * | |||
| 112 | memset(K, 0, ops->block_size); | 113 | memset(K, 0, ops->block_size); |
| 113 | if (key_len > ops->block_size) { | 114 | if (key_len > ops->block_size) { |
| 114 | /* Reduce the key first */ | 115 | /* Reduce the key first */ |
| 116 | #if PHP_VERSION_ID < 80100 | ||
| 115 | ops->hash_init(context); | 117 | ops->hash_init(context); |
| 118 | #else | ||
| 119 | ops->hash_init(context, NULL); | ||
| 120 | #endif | ||
| 116 | ops->hash_update(context, key, key_len); | 121 | ops->hash_update(context, key, key_len); |
| 117 | ops->hash_final(K, context); | 122 | ops->hash_final(K, context); |
| 118 | } else { | 123 | } else { |
| @@ -123,7 +128,11 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops * | |||
| 123 | } | 128 | } |
| 124 | 129 | ||
| 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) { | 130 | 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) { |
| 131 | #if PHP_VERSION_ID < 80100 | ||
| 126 | ops->hash_init(context); | 132 | ops->hash_init(context); |
| 133 | #else | ||
| 134 | ops->hash_init(context, NULL); | ||
| 135 | #endif | ||
| 127 | ops->hash_update(context, key, ops->block_size); | 136 | ops->hash_update(context, key, ops->block_size); |
| 128 | ops->hash_update(context, data, data_size); | 137 | ops->hash_update(context, data, data_size); |
| 129 | ops->hash_final(final, context); | 138 | ops->hash_final(final, context); |
