Lines Matching refs:context
206 static inline void Gost(PHP_GOST_CTX *context, uint32_t data[8]) in Gost() argument
209 uint32_t l, r, t, key[8], u[8], v[8], w[8], s[8], *h = context->state, *m = data; in Gost()
211 memcpy(u, context->state, sizeof(u)); in Gost()
215 PASS(*context->tables); in Gost()
223 static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32]) in GostTransform() argument
231 context->state[i + 8] += data[i] + temp; in GostTransform()
232 temp = context->state[i + 8] < data[i] ? 1 : (context->state[i + 8] == data[i] ? temp : 0); in GostTransform()
235 Gost(context, data); in GostTransform()
238 PHP_HASH_API void PHP_GOSTInit(PHP_GOST_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) in PHP_GOSTInit() argument
240 memset(context, 0, sizeof(*context)); in PHP_GOSTInit()
241 context->tables = &tables_test; in PHP_GOSTInit()
244 PHP_HASH_API void PHP_GOSTInitCrypto(PHP_GOST_CTX *context, ZEND_ATTRIBUTE_UNUSED HashTable *args) in PHP_GOSTInitCrypto() argument
246 PHP_GOSTInit(context, NULL); in PHP_GOSTInitCrypto()
247 context->tables = &tables_crypto; in PHP_GOSTInitCrypto()
252 PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *input, size_t len) in PHP_GOSTUpdate() argument
254 if ((MAX32 - context->count[0]) < (len * 8)) { in PHP_GOSTUpdate()
255 context->count[1]++; in PHP_GOSTUpdate()
256 context->count[0] = MAX32 - context->count[0]; in PHP_GOSTUpdate()
257 context->count[0] = (len * 8) - context->count[0]; in PHP_GOSTUpdate()
259 context->count[0] += len * 8; in PHP_GOSTUpdate()
262 if (context->length + len < 32) { in PHP_GOSTUpdate()
263 memcpy(&context->buffer[context->length], input, len); in PHP_GOSTUpdate()
264 context->length += (unsigned char)len; in PHP_GOSTUpdate()
266 size_t i = 0, r = (context->length + len) % 32; in PHP_GOSTUpdate()
268 if (context->length) { in PHP_GOSTUpdate()
269 i = 32 - context->length; in PHP_GOSTUpdate()
270 memcpy(&context->buffer[context->length], input, i); in PHP_GOSTUpdate()
271 GostTransform(context, context->buffer); in PHP_GOSTUpdate()
275 GostTransform(context, input + i); in PHP_GOSTUpdate()
278 memcpy(context->buffer, input + i, r); in PHP_GOSTUpdate()
279 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_GOSTUpdate()
280 context->length = (unsigned char)r; in PHP_GOSTUpdate()
284 PHP_HASH_API void PHP_GOSTFinal(unsigned char digest[32], PHP_GOST_CTX *context) in PHP_GOSTFinal() argument
288 if (context->length) { in PHP_GOSTFinal()
289 GostTransform(context, context->buffer); in PHP_GOSTFinal()
292 memcpy(l, context->count, sizeof(context->count)); in PHP_GOSTFinal()
293 Gost(context, l); in PHP_GOSTFinal()
294 memcpy(l, &context->state[8], sizeof(l)); in PHP_GOSTFinal()
295 Gost(context, l); in PHP_GOSTFinal()
298 digest[j] = (unsigned char) (context->state[i] & 0xff); in PHP_GOSTFinal()
299 digest[j + 1] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_GOSTFinal()
300 digest[j + 2] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_GOSTFinal()
301 digest[j + 3] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_GOSTFinal()
304 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_GOSTFinal()
309 PHP_GOST_CTX *ctx = (PHP_GOST_CTX *) hash->context; in php_gost_unserialize()