Lines Matching refs:context
121 static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char input[32]) in SnefruTransform() argument
126 context->state[8+j] = ((input[i] & 0xff) << 24) | ((input[i+1] & 0xff) << 16) | in SnefruTransform()
129 Snefru(context->state); in SnefruTransform()
130 ZEND_SECURE_ZERO(&context->state[8], sizeof(uint32_t) * 8); in SnefruTransform()
133 PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context) in PHP_SNEFRUInit() argument
135 memset(context, 0, sizeof(*context)); in PHP_SNEFRUInit()
140 PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len) in PHP_SNEFRUUpdate() argument
142 if ((MAX32 - context->count[1]) < (len * 8)) { in PHP_SNEFRUUpdate()
143 context->count[0]++; in PHP_SNEFRUUpdate()
144 context->count[1] = MAX32 - context->count[1]; in PHP_SNEFRUUpdate()
145 context->count[1] = (len * 8) - context->count[1]; in PHP_SNEFRUUpdate()
147 context->count[1] += len * 8; in PHP_SNEFRUUpdate()
150 if (context->length + len < 32) { in PHP_SNEFRUUpdate()
151 memcpy(&context->buffer[context->length], input, len); in PHP_SNEFRUUpdate()
152 context->length += (unsigned char)len; in PHP_SNEFRUUpdate()
154 size_t i = 0, r = (context->length + len) % 32; in PHP_SNEFRUUpdate()
156 if (context->length) { in PHP_SNEFRUUpdate()
157 i = 32 - context->length; in PHP_SNEFRUUpdate()
158 memcpy(&context->buffer[context->length], input, i); in PHP_SNEFRUUpdate()
159 SnefruTransform(context, context->buffer); in PHP_SNEFRUUpdate()
163 SnefruTransform(context, input + i); in PHP_SNEFRUUpdate()
166 memcpy(context->buffer, input + i, r); in PHP_SNEFRUUpdate()
167 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_SNEFRUUpdate()
168 context->length = (unsigned char)r; in PHP_SNEFRUUpdate()
172 PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context) in PHP_SNEFRUFinal() argument
176 if (context->length) { in PHP_SNEFRUFinal()
177 SnefruTransform(context, context->buffer); in PHP_SNEFRUFinal()
180 context->state[14] = context->count[0]; in PHP_SNEFRUFinal()
181 context->state[15] = context->count[1]; in PHP_SNEFRUFinal()
182 Snefru(context->state); in PHP_SNEFRUFinal()
185 digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_SNEFRUFinal()
186 digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_SNEFRUFinal()
187 digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_SNEFRUFinal()
188 digest[j + 3] = (unsigned char) (context->state[i] & 0xff); in PHP_SNEFRUFinal()
191 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_SNEFRUFinal()