Lines Matching refs:ctx
86 void mbedtls_md2_init( mbedtls_md2_context *ctx ) in mbedtls_md2_init() argument
88 memset( ctx, 0, sizeof( mbedtls_md2_context ) ); in mbedtls_md2_init()
91 void mbedtls_md2_free( mbedtls_md2_context *ctx ) in mbedtls_md2_free() argument
93 if( ctx == NULL ) in mbedtls_md2_free()
96 mbedtls_zeroize( ctx, sizeof( mbedtls_md2_context ) ); in mbedtls_md2_free()
108 void mbedtls_md2_starts( mbedtls_md2_context *ctx ) in mbedtls_md2_starts() argument
110 memset( ctx->cksum, 0, 16 ); in mbedtls_md2_starts()
111 memset( ctx->state, 0, 46 ); in mbedtls_md2_starts()
112 memset( ctx->buffer, 0, 16 ); in mbedtls_md2_starts()
113 ctx->left = 0; in mbedtls_md2_starts()
117 void mbedtls_md2_process( mbedtls_md2_context *ctx ) in mbedtls_md2_process() argument
124 ctx->state[i + 16] = ctx->buffer[i]; in mbedtls_md2_process()
125 ctx->state[i + 32] = in mbedtls_md2_process()
126 (unsigned char)( ctx->buffer[i] ^ ctx->state[i]); in mbedtls_md2_process()
133 ctx->state[j] = (unsigned char) in mbedtls_md2_process()
134 ( ctx->state[j] ^ PI_SUBST[t] ); in mbedtls_md2_process()
135 t = ctx->state[j]; in mbedtls_md2_process()
141 t = ctx->cksum[15]; in mbedtls_md2_process()
145 ctx->cksum[i] = (unsigned char) in mbedtls_md2_process()
146 ( ctx->cksum[i] ^ PI_SUBST[ctx->buffer[i] ^ t] ); in mbedtls_md2_process()
147 t = ctx->cksum[i]; in mbedtls_md2_process()
155 void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ) in mbedtls_md2_update() argument
161 if( ctx->left + ilen > 16 ) in mbedtls_md2_update()
162 fill = 16 - ctx->left; in mbedtls_md2_update()
166 memcpy( ctx->buffer + ctx->left, input, fill ); in mbedtls_md2_update()
168 ctx->left += fill; in mbedtls_md2_update()
172 if( ctx->left == 16 ) in mbedtls_md2_update()
174 ctx->left = 0; in mbedtls_md2_update()
175 mbedtls_md2_process( ctx ); in mbedtls_md2_update()
183 void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] ) in mbedtls_md2_finish() argument
188 x = (unsigned char)( 16 - ctx->left ); in mbedtls_md2_finish()
190 for( i = ctx->left; i < 16; i++ ) in mbedtls_md2_finish()
191 ctx->buffer[i] = x; in mbedtls_md2_finish()
193 mbedtls_md2_process( ctx ); in mbedtls_md2_finish()
195 memcpy( ctx->buffer, ctx->cksum, 16 ); in mbedtls_md2_finish()
196 mbedtls_md2_process( ctx ); in mbedtls_md2_finish()
198 memcpy( output, ctx->state, 16 ); in mbedtls_md2_finish()
208 mbedtls_md2_context ctx; in mbedtls_md2() local
210 mbedtls_md2_init( &ctx ); in mbedtls_md2()
211 mbedtls_md2_starts( &ctx ); in mbedtls_md2()
212 mbedtls_md2_update( &ctx, input, ilen ); in mbedtls_md2()
213 mbedtls_md2_finish( &ctx, output ); in mbedtls_md2()
214 mbedtls_md2_free( &ctx ); in mbedtls_md2()