Lines Matching refs:ctx

74 void sha1_starts( sha1_context *ctx )
76 ctx->total[0] = 0;
77 ctx->total[1] = 0;
79 ctx->state[0] = 0x67452301;
80 ctx->state[1] = 0xEFCDAB89;
81 ctx->state[2] = 0x98BADCFE;
82 ctx->state[3] = 0x10325476;
83 ctx->state[4] = 0xC3D2E1F0;
86 static void sha1_process( sha1_context *ctx, const unsigned char data[64] )
121 A = ctx->state[0];
122 B = ctx->state[1];
123 C = ctx->state[2];
124 D = ctx->state[3];
125 E = ctx->state[4];
235 ctx->state[0] += A;
236 ctx->state[1] += B;
237 ctx->state[2] += C;
238 ctx->state[3] += D;
239 ctx->state[4] += E;
245 void sha1_update( sha1_context *ctx, const unsigned char *input, int ilen )
253 left = ctx->total[0] & 0x3F;
256 ctx->total[0] += ilen;
257 ctx->total[0] &= 0xFFFFFFFF;
259 if( ctx->total[0] < (unsigned long) ilen )
260 ctx->total[1]++;
264 MEMCPY( (void *) (ctx->buffer + left),
266 sha1_process( ctx, ctx->buffer );
274 sha1_process( ctx, input );
281 MEMCPY( (void *) (ctx->buffer + left),
297 void sha1_finish( sha1_context *ctx, unsigned char output[20] )
303 high = ( ctx->total[0] >> 29 )
304 | ( ctx->total[1] << 3 );
305 low = ( ctx->total[0] << 3 );
310 last = ctx->total[0] & 0x3F;
313 sha1_update( ctx, sha1_padding, padn );
314 sha1_update( ctx, msglen, 8 );
316 PUT_ULONG_BE( ctx->state[0], output, 0 );
317 PUT_ULONG_BE( ctx->state[1], output, 4 );
318 PUT_ULONG_BE( ctx->state[2], output, 8 );
319 PUT_ULONG_BE( ctx->state[3], output, 12 );
320 PUT_ULONG_BE( ctx->state[4], output, 16 );
328 sha1_context ctx;
330 sha1_starts( &ctx );
331 sha1_update( &ctx, input, ilen );
332 sha1_finish( &ctx, output );