summaryrefslogtreecommitdiff
path: root/src/sp_php_compat.h
diff options
context:
space:
mode:
authorBen Fuhrmannek2021-11-30 12:57:06 +0100
committerBen Fuhrmannek2021-11-30 12:57:06 +0100
commite22065c7ba31d000e93f57dce8a2caae50375d5e (patch)
tree7703ecce07857a4bf64e1a2aae052d8795b6afc8 /src/sp_php_compat.h
parent0462573a7678468b19bc4865c75f7b82dbedbe03 (diff)
php 8.1 compatibility
Diffstat (limited to 'src/sp_php_compat.h')
-rw-r--r--src/sp_php_compat.h9
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
104static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const size_t length) { 105static 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
125static 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) { 130static 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);