Lines Matching refs:context
227 static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32]) in GostTransform() argument
235 save = context->state[i + 8]; in GostTransform()
236 context->state[i + 8] += data[i] + temp; in GostTransform()
237 temp = ((context->state[i + 8] < data[i]) || (context->state[i + 8] < save)) ? 1 : 0; in GostTransform()
240 Gost(context->state, data); in GostTransform()
243 PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context) in PHP_GOSTInit() argument
245 memset(context, 0, sizeof(*context)); in PHP_GOSTInit()
250 PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len) in PHP_GOSTUpdate() argument
252 if ((MAX32 - context->count[0]) < (len * 8)) { in PHP_GOSTUpdate()
253 context->count[1]++; in PHP_GOSTUpdate()
254 context->count[0] = MAX32 - context->count[0]; in PHP_GOSTUpdate()
255 context->count[0] = (len * 8) - context->count[0]; in PHP_GOSTUpdate()
257 context->count[0] += len * 8; in PHP_GOSTUpdate()
260 if (context->length + len < 32) { in PHP_GOSTUpdate()
261 memcpy(&context->buffer[context->length], input, len); in PHP_GOSTUpdate()
262 context->length += len; in PHP_GOSTUpdate()
264 size_t i = 0, r = (context->length + len) % 32; in PHP_GOSTUpdate()
266 if (context->length) { in PHP_GOSTUpdate()
267 i = 32 - context->length; in PHP_GOSTUpdate()
268 memcpy(&context->buffer[context->length], input, i); in PHP_GOSTUpdate()
269 GostTransform(context, context->buffer); in PHP_GOSTUpdate()
273 GostTransform(context, input + i); in PHP_GOSTUpdate()
276 memcpy(context->buffer, input + i, r); in PHP_GOSTUpdate()
277 memset(&context->buffer[r], 0, 32 - r); in PHP_GOSTUpdate()
278 context->length = r; in PHP_GOSTUpdate()
282 PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context) in PHP_GOSTFinal() argument
286 if (context->length) { in PHP_GOSTFinal()
287 GostTransform(context, context->buffer); in PHP_GOSTFinal()
290 memcpy(l, context->count, sizeof(context->count)); in PHP_GOSTFinal()
291 Gost(context->state, l); in PHP_GOSTFinal()
292 memcpy(l, &context->state[8], sizeof(l)); in PHP_GOSTFinal()
293 Gost(context->state, l); in PHP_GOSTFinal()
296 digest[j] = (unsigned char) (context->state[i] & 0xff); in PHP_GOSTFinal()
297 digest[j + 1] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_GOSTFinal()
298 digest[j + 2] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_GOSTFinal()
299 digest[j + 3] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_GOSTFinal()
302 memset(context, 0, sizeof(*context)); in PHP_GOSTFinal()