Lines Matching refs:context
123 static inline void SnefruTransform(PHP_SNEFRU_CTX *context, const unsigned char input[32]) in SnefruTransform() argument
128 context->state[8+j] = ((input[i] & 0xff) << 24) | ((input[i+1] & 0xff) << 16) | in SnefruTransform()
131 Snefru(context->state); in SnefruTransform()
132 ZEND_SECURE_ZERO(&context->state[8], sizeof(uint32_t) * 8); in SnefruTransform()
135 PHP_HASH_API void PHP_SNEFRUInit(PHP_SNEFRU_CTX *context) in PHP_SNEFRUInit() argument
137 memset(context, 0, sizeof(*context)); in PHP_SNEFRUInit()
142 PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char *input, size_t len) in PHP_SNEFRUUpdate() argument
144 if ((MAX32 - context->count[1]) < (len * 8)) { in PHP_SNEFRUUpdate()
145 context->count[0]++; in PHP_SNEFRUUpdate()
146 context->count[1] = MAX32 - context->count[1]; in PHP_SNEFRUUpdate()
147 context->count[1] = (len * 8) - context->count[1]; in PHP_SNEFRUUpdate()
149 context->count[1] += len * 8; in PHP_SNEFRUUpdate()
152 if (context->length + len < 32) { in PHP_SNEFRUUpdate()
153 memcpy(&context->buffer[context->length], input, len); in PHP_SNEFRUUpdate()
154 context->length += len; in PHP_SNEFRUUpdate()
156 size_t i = 0, r = (context->length + len) % 32; in PHP_SNEFRUUpdate()
158 if (context->length) { in PHP_SNEFRUUpdate()
159 i = 32 - context->length; in PHP_SNEFRUUpdate()
160 memcpy(&context->buffer[context->length], input, i); in PHP_SNEFRUUpdate()
161 SnefruTransform(context, context->buffer); in PHP_SNEFRUUpdate()
165 SnefruTransform(context, input + i); in PHP_SNEFRUUpdate()
168 memcpy(context->buffer, input + i, r); in PHP_SNEFRUUpdate()
169 ZEND_SECURE_ZERO(&context->buffer[r], 32 - r); in PHP_SNEFRUUpdate()
170 context->length = r; in PHP_SNEFRUUpdate()
174 PHP_HASH_API void PHP_SNEFRUFinal(unsigned char digest[32], PHP_SNEFRU_CTX *context) in PHP_SNEFRUFinal() argument
178 if (context->length) { in PHP_SNEFRUFinal()
179 SnefruTransform(context, context->buffer); in PHP_SNEFRUFinal()
182 context->state[14] = context->count[0]; in PHP_SNEFRUFinal()
183 context->state[15] = context->count[1]; in PHP_SNEFRUFinal()
184 Snefru(context->state); in PHP_SNEFRUFinal()
187 digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_SNEFRUFinal()
188 digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_SNEFRUFinal()
189 digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_SNEFRUFinal()
190 digest[j + 3] = (unsigned char) (context->state[i] & 0xff); in PHP_SNEFRUFinal()
193 ZEND_SECURE_ZERO(context, sizeof(*context)); in PHP_SNEFRUFinal()