/* * MD2 final digest */ void mbedtls_md2_finish( mbedtls_md2_context *ctx, unsigned char output[16] ) { size_t i; unsigned char x; x = (unsigned char)( 16 - ctx->left ); for( i = ctx->left; i < 16; i++ ) ctx->buffer[i] = x; mbedtls_md2_process( ctx ); memcpy( ctx->buffer, ctx->cksum, 16 ); mbedtls_md2_process( ctx ); memcpy( output, ctx->state, 16 ); }
/* * MD2 process buffer */ void mbedtls_md2_update( mbedtls_md2_context *ctx, const unsigned char *input, size_t ilen ) { size_t fill; while( ilen > 0 ) { if( ilen > 16 - ctx->left ) fill = 16 - ctx->left; else fill = ilen; memcpy( ctx->buffer + ctx->left, input, fill ); ctx->left += fill; input += fill; ilen -= fill; if( ctx->left == 16 ) { ctx->left = 0; mbedtls_md2_process( ctx ); } } }
static void md2_process_wrap( void *ctx, const unsigned char *data ) { ((void) data); mbedtls_md2_process( (mbedtls_md2_context *) ctx ); }