Lines Matching refs:context
119 static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char input[32]) in SnefruTransform() argument
124 context->state[8+j] = ((unsigned)input[i] << 24) | ((unsigned)input[i+1] << 16) | in SnefruTransform()
127 Snefru(context->state); in SnefruTransform()
128 ZEND_SECURE_ZERO(&context->state[8], sizeof(uint32_t) * 8); in SnefruTransform()
131 PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) in PHP_SNEFRUInit() argument
133 memset(context, 0, sizeof(*context)); in PHP_SNEFRUInit()
138 PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len) in PHP_SNEFRUUpdate() argument
140 if ((MAX32 - context->count[1]) < (len * 8)) { in PHP_SNEFRUUpdate()
141 context->count[0]++; in PHP_SNEFRUUpdate()
142 context->count[1] = MAX32 - context->count[1]; in PHP_SNEFRUUpdate()
143 context->count[1] = ((uint32_t) len * 8) - context->count[1]; in PHP_SNEFRUUpdate()
145 context->count[1] += (uint32_t) len * 8; in PHP_SNEFRUUpdate()
148 if (context->length + len < 32) { in PHP_SNEFRUUpdate()
149 memcpy(&context->buffer[context->length], input, len); in PHP_SNEFRUUpdate()
150 context->length += (unsigned char)len; in PHP_SNEFRUUpdate()
152 size_t i = 0, r = (context->length + len) % 32; in PHP_SNEFRUUpdate()
154 if (context->length) { in PHP_SNEFRUUpdate()
155 i = 32 - context->length; in PHP_SNEFRUUpdate()
156 memcpy(&context->buffer[context->length], input, i); in PHP_SNEFRUUpdate()
157 SnefruTransform(context, context->buffer); in PHP_SNEFRUUpdate()
161 SnefruTransform(context, input + i); in PHP_SNEFRUUpdate()
164 memcpy(context->buffer, input + i, r); in PHP_SNEFRUUpdate()
165 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_SNEFRUUpdate()
166 context->length = (unsigned char)r; in PHP_SNEFRUUpdate()
170 PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context) in PHP_SNEFRUFinal() argument
174 if (context->length) { in PHP_SNEFRUFinal()
175 SnefruTransform(context, context->buffer); in PHP_SNEFRUFinal()
178 context->state[14] = context->count[0]; in PHP_SNEFRUFinal()
179 context->state[15] = context->count[1]; in PHP_SNEFRUFinal()
180 Snefru(context->state); in PHP_SNEFRUFinal()
183 digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_SNEFRUFinal()
184 digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_SNEFRUFinal()
185 digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_SNEFRUFinal()
186 digest[j + 3] = (unsigned char) (context->state[i] & 0xff); in PHP_SNEFRUFinal()
189 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_SNEFRUFinal()
194 PHP_SNEFRU_CTX *ctx = (PHP_SNEFRU_CTX *) hash->context; in php_snefru_unserialize()