Lines Matching refs:context

210 static inline void Gost(PHP_GOST_CTX *context, php_hash_uint32 data[8])  in Gost()  argument
213 php_hash_uint32 l, r, t, key[8], u[8], v[8], w[8], s[8], *h = context->state, *m = data; in Gost()
215 memcpy(u, context->state, sizeof(u)); in Gost()
219 PASS(*context->tables); in Gost()
227 static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32]) in GostTransform() argument
235 context->state[i + 8] += data[i] + temp; in GostTransform()
236 temp = context->state[i + 8] < data[i] ? 1 : (context->state[i + 8] == data[i] ? temp : 0); in GostTransform()
239 Gost(context, data); in GostTransform()
242 PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context) in PHP_GOSTInit() argument
244 memset(context, 0, sizeof(*context)); in PHP_GOSTInit()
245 context->tables = &tables_test; in PHP_GOSTInit()
248 PHP_HASH_API void PHP_GOSTInitCrypto(PHP_GOST_CTX *context) in PHP_GOSTInitCrypto() argument
250 PHP_GOSTInit(context); in PHP_GOSTInitCrypto()
251 context->tables = &tables_crypto; in PHP_GOSTInitCrypto()
256 PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len) in PHP_GOSTUpdate() argument
258 if ((MAX32 - context->count[0]) < (len * 8)) { in PHP_GOSTUpdate()
259 context->count[1]++; in PHP_GOSTUpdate()
260 context->count[0] = MAX32 - context->count[0]; in PHP_GOSTUpdate()
261 context->count[0] = (len * 8) - context->count[0]; in PHP_GOSTUpdate()
263 context->count[0] += len * 8; in PHP_GOSTUpdate()
266 if (context->length + len < 32) { in PHP_GOSTUpdate()
267 memcpy(&context->buffer[context->length], input, len); in PHP_GOSTUpdate()
268 context->length += len; in PHP_GOSTUpdate()
270 size_t i = 0, r = (context->length + len) % 32; in PHP_GOSTUpdate()
272 if (context->length) { in PHP_GOSTUpdate()
273 i = 32 - context->length; in PHP_GOSTUpdate()
274 memcpy(&context->buffer[context->length], input, i); in PHP_GOSTUpdate()
275 GostTransform(context, context->buffer); in PHP_GOSTUpdate()
279 GostTransform(context, input + i); in PHP_GOSTUpdate()
282 memcpy(context->buffer, input + i, r); in PHP_GOSTUpdate()
283 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_GOSTUpdate()
284 context->length = r; in PHP_GOSTUpdate()
288 PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context) in PHP_GOSTFinal() argument
292 if (context->length) { in PHP_GOSTFinal()
293 GostTransform(context, context->buffer); in PHP_GOSTFinal()
296 memcpy(l, context->count, sizeof(context->count)); in PHP_GOSTFinal()
297 Gost(context, l); in PHP_GOSTFinal()
298 memcpy(l, &context->state[8], sizeof(l)); in PHP_GOSTFinal()
299 Gost(context, l); in PHP_GOSTFinal()
302 digest[j] = (unsigned char) (context->state[i] & 0xff); in PHP_GOSTFinal()
303 digest[j + 1] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_GOSTFinal()
304 digest[j + 2] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_GOSTFinal()
305 digest[j + 3] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_GOSTFinal()
308 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_GOSTFinal()