Lines Matching refs:ctx
95 void mbedtls_sha512_init( mbedtls_sha512_context *ctx ) in mbedtls_sha512_init() argument
97 memset( ctx, 0, sizeof( mbedtls_sha512_context ) ); in mbedtls_sha512_init()
100 void mbedtls_sha512_free( mbedtls_sha512_context *ctx ) in mbedtls_sha512_free() argument
102 if( ctx == NULL ) in mbedtls_sha512_free()
105 mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) ); in mbedtls_sha512_free()
117 void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 ) in mbedtls_sha512_starts() argument
119 ctx->total[0] = 0; in mbedtls_sha512_starts()
120 ctx->total[1] = 0; in mbedtls_sha512_starts()
125 ctx->state[0] = UL64(0x6A09E667F3BCC908); in mbedtls_sha512_starts()
126 ctx->state[1] = UL64(0xBB67AE8584CAA73B); in mbedtls_sha512_starts()
127 ctx->state[2] = UL64(0x3C6EF372FE94F82B); in mbedtls_sha512_starts()
128 ctx->state[3] = UL64(0xA54FF53A5F1D36F1); in mbedtls_sha512_starts()
129 ctx->state[4] = UL64(0x510E527FADE682D1); in mbedtls_sha512_starts()
130 ctx->state[5] = UL64(0x9B05688C2B3E6C1F); in mbedtls_sha512_starts()
131 ctx->state[6] = UL64(0x1F83D9ABFB41BD6B); in mbedtls_sha512_starts()
132 ctx->state[7] = UL64(0x5BE0CD19137E2179); in mbedtls_sha512_starts()
137 ctx->state[0] = UL64(0xCBBB9D5DC1059ED8); in mbedtls_sha512_starts()
138 ctx->state[1] = UL64(0x629A292A367CD507); in mbedtls_sha512_starts()
139 ctx->state[2] = UL64(0x9159015A3070DD17); in mbedtls_sha512_starts()
140 ctx->state[3] = UL64(0x152FECD8F70E5939); in mbedtls_sha512_starts()
141 ctx->state[4] = UL64(0x67332667FFC00B31); in mbedtls_sha512_starts()
142 ctx->state[5] = UL64(0x8EB44A8768581511); in mbedtls_sha512_starts()
143 ctx->state[6] = UL64(0xDB0C2E0D64F98FA7); in mbedtls_sha512_starts()
144 ctx->state[7] = UL64(0x47B5481DBEFA4FA4); in mbedtls_sha512_starts()
147 ctx->is384 = is384; in mbedtls_sha512_starts()
199 void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] ) in mbedtls_sha512_process() argument
235 A = ctx->state[0]; in mbedtls_sha512_process()
236 B = ctx->state[1]; in mbedtls_sha512_process()
237 C = ctx->state[2]; in mbedtls_sha512_process()
238 D = ctx->state[3]; in mbedtls_sha512_process()
239 E = ctx->state[4]; in mbedtls_sha512_process()
240 F = ctx->state[5]; in mbedtls_sha512_process()
241 G = ctx->state[6]; in mbedtls_sha512_process()
242 H = ctx->state[7]; in mbedtls_sha512_process()
258 ctx->state[0] += A; in mbedtls_sha512_process()
259 ctx->state[1] += B; in mbedtls_sha512_process()
260 ctx->state[2] += C; in mbedtls_sha512_process()
261 ctx->state[3] += D; in mbedtls_sha512_process()
262 ctx->state[4] += E; in mbedtls_sha512_process()
263 ctx->state[5] += F; in mbedtls_sha512_process()
264 ctx->state[6] += G; in mbedtls_sha512_process()
265 ctx->state[7] += H; in mbedtls_sha512_process()
272 void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input, in mbedtls_sha512_update() argument
281 left = (unsigned int) (ctx->total[0] & 0x7F); in mbedtls_sha512_update()
284 ctx->total[0] += (uint64_t) ilen; in mbedtls_sha512_update()
286 if( ctx->total[0] < (uint64_t) ilen ) in mbedtls_sha512_update()
287 ctx->total[1]++; in mbedtls_sha512_update()
291 memcpy( (void *) (ctx->buffer + left), input, fill ); in mbedtls_sha512_update()
292 mbedtls_sha512_process( ctx, ctx->buffer ); in mbedtls_sha512_update()
300 mbedtls_sha512_process( ctx, input ); in mbedtls_sha512_update()
306 memcpy( (void *) (ctx->buffer + left), input, ilen ); in mbedtls_sha512_update()
324 void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] ) in mbedtls_sha512_finish() argument
330 high = ( ctx->total[0] >> 61 ) in mbedtls_sha512_finish()
331 | ( ctx->total[1] << 3 ); in mbedtls_sha512_finish()
332 low = ( ctx->total[0] << 3 ); in mbedtls_sha512_finish()
337 last = (size_t)( ctx->total[0] & 0x7F ); in mbedtls_sha512_finish()
340 mbedtls_sha512_update( ctx, sha512_padding, padn ); in mbedtls_sha512_finish()
341 mbedtls_sha512_update( ctx, msglen, 16 ); in mbedtls_sha512_finish()
343 PUT_UINT64_BE( ctx->state[0], output, 0 ); in mbedtls_sha512_finish()
344 PUT_UINT64_BE( ctx->state[1], output, 8 ); in mbedtls_sha512_finish()
345 PUT_UINT64_BE( ctx->state[2], output, 16 ); in mbedtls_sha512_finish()
346 PUT_UINT64_BE( ctx->state[3], output, 24 ); in mbedtls_sha512_finish()
347 PUT_UINT64_BE( ctx->state[4], output, 32 ); in mbedtls_sha512_finish()
348 PUT_UINT64_BE( ctx->state[5], output, 40 ); in mbedtls_sha512_finish()
350 if( ctx->is384 == 0 ) in mbedtls_sha512_finish()
352 PUT_UINT64_BE( ctx->state[6], output, 48 ); in mbedtls_sha512_finish()
353 PUT_UINT64_BE( ctx->state[7], output, 56 ); in mbedtls_sha512_finish()
365 mbedtls_sha512_context ctx; in mbedtls_sha512() local
367 mbedtls_sha512_init( &ctx ); in mbedtls_sha512()
368 mbedtls_sha512_starts( &ctx, is384 ); in mbedtls_sha512()
369 mbedtls_sha512_update( &ctx, input, ilen ); in mbedtls_sha512()
370 mbedtls_sha512_finish( &ctx, output ); in mbedtls_sha512()
371 mbedtls_sha512_free( &ctx ); in mbedtls_sha512()
453 mbedtls_sha512_context ctx; in mbedtls_sha512_self_test() local
464 mbedtls_sha512_init( &ctx ); in mbedtls_sha512_self_test()
474 mbedtls_sha512_starts( &ctx, k ); in mbedtls_sha512_self_test()
481 mbedtls_sha512_update( &ctx, buf, buflen ); in mbedtls_sha512_self_test()
484 mbedtls_sha512_update( &ctx, sha512_test_buf[j], in mbedtls_sha512_self_test()
487 mbedtls_sha512_finish( &ctx, sha512sum ); in mbedtls_sha512_self_test()
506 mbedtls_sha512_free( &ctx ); in mbedtls_sha512_self_test()