Computing MD5 digest for large data file with Intel IPP functions

The MD5 functions in Intel IPP Cryptographic domain provide an easy and fast way to compute the MD5 digest for file data. If the code only need to compute on small amount of data, users can call Intel IPP MD5MessageDigest() function. Please check the Example 3-1 MD5 Digest of a Messageat Intel IPP cryptographic function manual.

If input data are larger than 2G bytes, users need to divide the data into small blocks, and then call ippsMD5Update () for each block data. The following code example provides the steps on using this function:

//data size is larger than 2G, use LONGLONG type as the input data length.
IppStatus MD5MessageDigestForLargeData(const Ipp8u *src, LONGLONG src_size, Ipp8u *pMD) 
	int	size;
	int	remainder;
                const int block_size = 0x7FFFFFFF; // 2GB - 1B
	LONGLONG long_block_size;
	IppsMD5State *ctx;

	ctx = (IppsMD5State *)malloc(size);
	if (ctx == NULL) {
		return ippStsMemAllocErr;
	if ((src_size < 0) || (src == NULL) || (pMD == NULL)) {
		return ippStsBadArgErr;
	for (long_block_size = 0; long_block_size < (src_size - block_size); long_block_size += block_size) {
		ippsMD5Update(src + long_block_size, block_size, ctx);
	remainder = (int)(src_size - long_block_size);
	if (remainder > 0) {
		ippsMD5Update(src + long_block_size, remainder, ctx);
	ippsMD5Final(pMD, ctx);
	return ippStsNoErr;
Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.