Lines Matching refs:ctx

81 void mbedtls_sha256_init( mbedtls_sha256_context *ctx )  in mbedtls_sha256_init()  argument
83 memset( ctx, 0, sizeof( mbedtls_sha256_context ) ); in mbedtls_sha256_init()
86 void mbedtls_sha256_free( mbedtls_sha256_context *ctx ) in mbedtls_sha256_free() argument
88 if( ctx == NULL ) in mbedtls_sha256_free()
91 mbedtls_zeroize( ctx, sizeof( mbedtls_sha256_context ) ); in mbedtls_sha256_free()
103 void mbedtls_sha256_starts( mbedtls_sha256_context *ctx, int is224 ) in mbedtls_sha256_starts() argument
105 ctx->total[0] = 0; in mbedtls_sha256_starts()
106 ctx->total[1] = 0; in mbedtls_sha256_starts()
111 ctx->state[0] = 0x6A09E667; in mbedtls_sha256_starts()
112 ctx->state[1] = 0xBB67AE85; in mbedtls_sha256_starts()
113 ctx->state[2] = 0x3C6EF372; in mbedtls_sha256_starts()
114 ctx->state[3] = 0xA54FF53A; in mbedtls_sha256_starts()
115 ctx->state[4] = 0x510E527F; in mbedtls_sha256_starts()
116 ctx->state[5] = 0x9B05688C; in mbedtls_sha256_starts()
117 ctx->state[6] = 0x1F83D9AB; in mbedtls_sha256_starts()
118 ctx->state[7] = 0x5BE0CD19; in mbedtls_sha256_starts()
123 ctx->state[0] = 0xC1059ED8; in mbedtls_sha256_starts()
124 ctx->state[1] = 0x367CD507; in mbedtls_sha256_starts()
125 ctx->state[2] = 0x3070DD17; in mbedtls_sha256_starts()
126 ctx->state[3] = 0xF70E5939; in mbedtls_sha256_starts()
127 ctx->state[4] = 0xFFC00B31; in mbedtls_sha256_starts()
128 ctx->state[5] = 0x68581511; in mbedtls_sha256_starts()
129 ctx->state[6] = 0x64F98FA7; in mbedtls_sha256_starts()
130 ctx->state[7] = 0xBEFA4FA4; in mbedtls_sha256_starts()
133 ctx->is224 = is224; in mbedtls_sha256_starts()
182 void mbedtls_sha256_process( mbedtls_sha256_context *ctx, const unsigned char data[64] ) in mbedtls_sha256_process() argument
189 A[i] = ctx->state[i]; in mbedtls_sha256_process()
234 ctx->state[i] += A[i]; in mbedtls_sha256_process()
241 void mbedtls_sha256_update( mbedtls_sha256_context *ctx, const unsigned char *input, in mbedtls_sha256_update() argument
250 left = ctx->total[0] & 0x3F; in mbedtls_sha256_update()
253 ctx->total[0] += (uint32_t) ilen; in mbedtls_sha256_update()
254 ctx->total[0] &= 0xFFFFFFFF; in mbedtls_sha256_update()
256 if( ctx->total[0] < (uint32_t) ilen ) in mbedtls_sha256_update()
257 ctx->total[1]++; in mbedtls_sha256_update()
261 memcpy( (void *) (ctx->buffer + left), input, fill ); in mbedtls_sha256_update()
262 mbedtls_sha256_process( ctx, ctx->buffer ); in mbedtls_sha256_update()
270 mbedtls_sha256_process( ctx, input ); in mbedtls_sha256_update()
276 memcpy( (void *) (ctx->buffer + left), input, ilen ); in mbedtls_sha256_update()
290 void mbedtls_sha256_finish( mbedtls_sha256_context *ctx, unsigned char output[32] ) in mbedtls_sha256_finish() argument
296 high = ( ctx->total[0] >> 29 ) in mbedtls_sha256_finish()
297 | ( ctx->total[1] << 3 ); in mbedtls_sha256_finish()
298 low = ( ctx->total[0] << 3 ); in mbedtls_sha256_finish()
303 last = ctx->total[0] & 0x3F; in mbedtls_sha256_finish()
306 mbedtls_sha256_update( ctx, sha256_padding, padn ); in mbedtls_sha256_finish()
307 mbedtls_sha256_update( ctx, msglen, 8 ); in mbedtls_sha256_finish()
309 PUT_UINT32_BE( ctx->state[0], output, 0 ); in mbedtls_sha256_finish()
310 PUT_UINT32_BE( ctx->state[1], output, 4 ); in mbedtls_sha256_finish()
311 PUT_UINT32_BE( ctx->state[2], output, 8 ); in mbedtls_sha256_finish()
312 PUT_UINT32_BE( ctx->state[3], output, 12 ); in mbedtls_sha256_finish()
313 PUT_UINT32_BE( ctx->state[4], output, 16 ); in mbedtls_sha256_finish()
314 PUT_UINT32_BE( ctx->state[5], output, 20 ); in mbedtls_sha256_finish()
315 PUT_UINT32_BE( ctx->state[6], output, 24 ); in mbedtls_sha256_finish()
317 if( ctx->is224 == 0 ) in mbedtls_sha256_finish()
318 PUT_UINT32_BE( ctx->state[7], output, 28 ); in mbedtls_sha256_finish()
329 mbedtls_sha256_context ctx; in mbedtls_sha256() local
331 mbedtls_sha256_init( &ctx ); in mbedtls_sha256()
332 mbedtls_sha256_starts( &ctx, is224 ); in mbedtls_sha256()
333 mbedtls_sha256_update( &ctx, input, ilen ); in mbedtls_sha256()
334 mbedtls_sha256_finish( &ctx, output ); in mbedtls_sha256()
335 mbedtls_sha256_free( &ctx ); in mbedtls_sha256()
397 mbedtls_sha256_context ctx; in mbedtls_sha256_self_test() local
408 mbedtls_sha256_init( &ctx ); in mbedtls_sha256_self_test()
418 mbedtls_sha256_starts( &ctx, k ); in mbedtls_sha256_self_test()
425 mbedtls_sha256_update( &ctx, buf, buflen ); in mbedtls_sha256_self_test()
428 mbedtls_sha256_update( &ctx, sha256_test_buf[j], in mbedtls_sha256_self_test()
431 mbedtls_sha256_finish( &ctx, sha256sum ); in mbedtls_sha256_self_test()
450 mbedtls_sha256_free( &ctx ); in mbedtls_sha256_self_test()