Lines Matching refs:context

208 static inline void Gost(PHP_GOST_CTX *context, uint32_t data[8])  in Gost()  argument
211 uint32_t l, r, t, key[8], u[8], v[8], w[8], s[8], *h = context->state, *m = data; in Gost()
213 memcpy(u, context->state, sizeof(u)); in Gost()
217 PASS(*context->tables); in Gost()
225 static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32]) in GostTransform() argument
233 context->state[i + 8] += data[i] + temp; in GostTransform()
234 temp = context->state[i + 8] < data[i] ? 1 : (context->state[i + 8] == data[i] ? temp : 0); in GostTransform()
237 Gost(context, data); in GostTransform()
240 PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context) in PHP_GOSTInit() argument
242 memset(context, 0, sizeof(*context)); in PHP_GOSTInit()
243 context->tables = &tables_test; in PHP_GOSTInit()
246 PHP_HASH_API void PHP_GOSTInitCrypto(PHP_GOST_CTX *context) in PHP_GOSTInitCrypto() argument
248 PHP_GOSTInit(context); in PHP_GOSTInitCrypto()
249 context->tables = &tables_crypto; in PHP_GOSTInitCrypto()
254 PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len) in PHP_GOSTUpdate() argument
256 if ((MAX32 - context->count[0]) < (len * 8)) { in PHP_GOSTUpdate()
257 context->count[1]++; in PHP_GOSTUpdate()
258 context->count[0] = MAX32 - context->count[0]; in PHP_GOSTUpdate()
259 context->count[0] = (len * 8) - context->count[0]; in PHP_GOSTUpdate()
261 context->count[0] += len * 8; in PHP_GOSTUpdate()
264 if (context->length + len < 32) { in PHP_GOSTUpdate()
265 memcpy(&context->buffer[context->length], input, len); in PHP_GOSTUpdate()
266 context->length += (unsigned char)len; in PHP_GOSTUpdate()
268 size_t i = 0, r = (context->length + len) % 32; in PHP_GOSTUpdate()
270 if (context->length) { in PHP_GOSTUpdate()
271 i = 32 - context->length; in PHP_GOSTUpdate()
272 memcpy(&context->buffer[context->length], input, i); in PHP_GOSTUpdate()
273 GostTransform(context, context->buffer); in PHP_GOSTUpdate()
277 GostTransform(context, input + i); in PHP_GOSTUpdate()
280 memcpy(context->buffer, input + i, r); in PHP_GOSTUpdate()
281 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_GOSTUpdate()
282 context->length = (unsigned char)r; in PHP_GOSTUpdate()
286 PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context) in PHP_GOSTFinal() argument
290 if (context->length) { in PHP_GOSTFinal()
291 GostTransform(context, context->buffer); in PHP_GOSTFinal()
294 memcpy(l, context->count, sizeof(context->count)); in PHP_GOSTFinal()
295 Gost(context, l); in PHP_GOSTFinal()
296 memcpy(l, &context->state[8], sizeof(l)); in PHP_GOSTFinal()
297 Gost(context, l); in PHP_GOSTFinal()
300 digest[j] = (unsigned char) (context->state[i] & 0xff); in PHP_GOSTFinal()
301 digest[j + 1] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_GOSTFinal()
302 digest[j + 2] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_GOSTFinal()
303 digest[j + 3] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_GOSTFinal()
306 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_GOSTFinal()