Lines Matching refs:ctx

77 void mbedtls_md2_init( mbedtls_md2_context *ctx )  in mbedtls_md2_init()  argument
79 memset( ctx, 0, sizeof( mbedtls_md2_context ) ); in mbedtls_md2_init()
82 void mbedtls_md2_free( mbedtls_md2_context *ctx ) in mbedtls_md2_free() argument
84 if( ctx == NULL ) in mbedtls_md2_free()
87 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md2_context ) ); in mbedtls_md2_free()
99 int mbedtls_md2_starts_ret( mbedtls_md2_context *ctx ) in mbedtls_md2_starts_ret() argument
101 memset( ctx->cksum, 0, 16 ); in mbedtls_md2_starts_ret()
102 memset( ctx->state, 0, 46 ); in mbedtls_md2_starts_ret()
103 memset( ctx->buffer, 0, 16 ); in mbedtls_md2_starts_ret()
104 ctx->left = 0; in mbedtls_md2_starts_ret()
110 void mbedtls_md2_starts( mbedtls_md2_context *ctx ) in mbedtls_md2_starts() argument
112 mbedtls_md2_starts_ret( ctx ); in mbedtls_md2_starts()
117 int mbedtls_internal_md2_process( mbedtls_md2_context *ctx ) in mbedtls_internal_md2_process() argument
124 ctx->state[i + 16] = ctx->buffer[i]; in mbedtls_internal_md2_process()
125 ctx->state[i + 32] = in mbedtls_internal_md2_process()
126 (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); in mbedtls_internal_md2_process()
133 ctx->state[j] = (unsigned char) in mbedtls_internal_md2_process()
134 ( ctx->state[j] ^ PI_SUBST[t] ); in mbedtls_internal_md2_process()
135 t = ctx->state[j]; in mbedtls_internal_md2_process()
141 t = ctx->cksum[15]; in mbedtls_internal_md2_process()
145 ctx->cksum[i] = (unsigned char) in mbedtls_internal_md2_process()
146 ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); in mbedtls_internal_md2_process()
147 t = ctx->cksum[i]; in mbedtls_internal_md2_process()
157 void mbedtls_md2_process( mbedtls_md2_context *ctx ) in mbedtls_md2_process() argument
159 mbedtls_internal_md2_process( ctx ); in mbedtls_md2_process()
167 int mbedtls_md2_update_ret( mbedtls_md2_context *ctx, in mbedtls_md2_update_ret() argument
176 if( ilen > 16 - ctx->left ) in mbedtls_md2_update_ret()
177 fill = 16 - ctx->left; in mbedtls_md2_update_ret()
181 memcpy( ctx->buffer + ctx->left, input, fill ); in mbedtls_md2_update_ret()
183 ctx->left += fill; in mbedtls_md2_update_ret()
187 if( ctx->left == 16 ) in mbedtls_md2_update_ret()
189 ctx->left = 0; in mbedtls_md2_update_ret()
190 if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 ) in mbedtls_md2_update_ret()
199 void mbedtls_md2_update( mbedtls_md2_context *ctx, in mbedtls_md2_update() argument
203 mbedtls_md2_update_ret( ctx, input, ilen ); in mbedtls_md2_update()
210 int mbedtls_md2_finish_ret( mbedtls_md2_context *ctx, in mbedtls_md2_finish_ret() argument
217 x = (unsigned char)( 16 - ctx->left ); in mbedtls_md2_finish_ret()
219 for( i = ctx->left; i < 16; i++ ) in mbedtls_md2_finish_ret()
220 ctx->buffer[i] = x; in mbedtls_md2_finish_ret()
222 if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 ) in mbedtls_md2_finish_ret()
225 memcpy( ctx->buffer, ctx->cksum, 16 ); in mbedtls_md2_finish_ret()
226 if( ( ret = mbedtls_internal_md2_process( ctx ) ) != 0 ) in mbedtls_md2_finish_ret()
229 memcpy( output, ctx->state, 16 ); in mbedtls_md2_finish_ret()
235 void mbedtls_md2_finish( mbedtls_md2_context *ctx, in mbedtls_md2_finish() argument
238 mbedtls_md2_finish_ret( ctx, output ); in mbedtls_md2_finish()
252 mbedtls_md2_context ctx; in mbedtls_md2_ret() local
254 mbedtls_md2_init( &ctx ); in mbedtls_md2_ret()
256 if( ( ret = mbedtls_md2_starts_ret( &ctx ) ) != 0 ) in mbedtls_md2_ret()
259 if( ( ret = mbedtls_md2_update_ret( &ctx, input, ilen ) ) != 0 ) in mbedtls_md2_ret()
262 if( ( ret = mbedtls_md2_finish_ret( &ctx, output ) ) != 0 ) in mbedtls_md2_ret()
266 mbedtls_md2_free( &ctx ); in mbedtls_md2_ret()