Lines Matching refs:context
121 static inline void SalsaTransform(PHP_SALSA_CTX *context, const unsigned char input[64]) in SalsaTransform() argument
134 if (!context->init) { in SalsaTransform()
135 memcpy(context->state, a, sizeof(a)); in SalsaTransform()
136 context->init = 1; in SalsaTransform()
139 context->Transform(context->state, a); in SalsaTransform()
143 PHP_HASH_API void PHP_SALSA10Init(PHP_SALSA_CTX *context) in PHP_SALSA10Init() argument
145 memset(context, 0, sizeof(*context)); in PHP_SALSA10Init()
146 context->Transform = Salsa10; in PHP_SALSA10Init()
149 PHP_HASH_API void PHP_SALSA20Init(PHP_SALSA_CTX *context) in PHP_SALSA20Init() argument
151 memset(context, 0, sizeof(*context)); in PHP_SALSA20Init()
152 context->Transform = Salsa20; in PHP_SALSA20Init()
155 PHP_HASH_API void PHP_SALSAUpdate(PHP_SALSA_CTX *context, const unsigned char *input, size_t len) in PHP_SALSAUpdate() argument
157 if (context->length + len < 64) { in PHP_SALSAUpdate()
158 memcpy(&context->buffer[context->length], input, len); in PHP_SALSAUpdate()
159 context->length += len; in PHP_SALSAUpdate()
161 size_t i = 0, r = (context->length + len) % 64; in PHP_SALSAUpdate()
163 if (context->length) { in PHP_SALSAUpdate()
164 i = 64 - context->length; in PHP_SALSAUpdate()
165 memcpy(&context->buffer[context->length], input, i); in PHP_SALSAUpdate()
166 SalsaTransform(context, context->buffer); in PHP_SALSAUpdate()
167 memset(context->buffer, 0, 64); in PHP_SALSAUpdate()
171 SalsaTransform(context, input + i); in PHP_SALSAUpdate()
174 memcpy(context->buffer, input + i, r); in PHP_SALSAUpdate()
175 context->length = r; in PHP_SALSAUpdate()
179 PHP_HASH_API void PHP_SALSAFinal(unsigned char digest[64], PHP_SALSA_CTX *context) in PHP_SALSAFinal() argument
183 if (context->length) { in PHP_SALSAFinal()
184 SalsaTransform(context, context->buffer); in PHP_SALSAFinal()
188 digest[j] = (unsigned char) ((context->state[i] >> 24) & 0xff); in PHP_SALSAFinal()
189 digest[j + 1] = (unsigned char) ((context->state[i] >> 16) & 0xff); in PHP_SALSAFinal()
190 digest[j + 2] = (unsigned char) ((context->state[i] >> 8) & 0xff); in PHP_SALSAFinal()
191 digest[j + 3] = (unsigned char) (context->state[i] & 0xff); in PHP_SALSAFinal()
194 memset(context, 0, sizeof(*context)); in PHP_SALSAFinal()