RTSha256Digest.cpp revision cbf12315646559bf0cb5f12957f6096cb73e30f4
af062818b47340eef15700d2f0211576ba3506eevboxsync * IPRT - SHA256 digest creation
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2009-2013 Oracle Corporation
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
af062818b47340eef15700d2f0211576ba3506eevboxsync * The contents of this file may alternatively be used under the terms
af062818b47340eef15700d2f0211576ba3506eevboxsync * of the Common Development and Distribution License Version 1.0
af062818b47340eef15700d2f0211576ba3506eevboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution, in which case the provisions of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * CDDL are applicable instead of those of the GPL.
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * You may elect to license modified versions of this file under the
4b9d6701570cb98fd36e209314239d104ec584d3vboxsync * terms and conditions of either the GPL or the CDDL or both.
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync/*******************************************************************************
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync* Header Files *
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync*******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsyncRTR3DECL(int) RTSha256Digest(void* pvBuf, size_t cbBuf, char **ppszDigest, PFNRTPROGRESS pfnProgressCallback, void *pvUser)
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Validate input */
af062818b47340eef15700d2f0211576ba3506eevboxsync AssertPtrNullReturn(pfnProgressCallback, VERR_INVALID_PARAMETER);
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Initialize OpenSSL. */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Buffer size for progress callback */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Working buffer */
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync /* Process the memory in blocks */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Call the progress callback if one is defined */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = pfnProgressCallback((unsigned)(cbReadTotal * rdMulti), pvUser);
af062818b47340eef15700d2f0211576ba3506eevboxsync break; /* canceled */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Finished? */
af062818b47340eef15700d2f0211576ba3506eevboxsync /* Finally calculate & format the SHA256 sum */
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = RTStrAllocEx(&pszDigest, RTSHA256_DIGEST_LEN + 1);
af062818b47340eef15700d2f0211576ba3506eevboxsync rc = RTSha256ToString(auchDig, pszDigest, RTSHA256_DIGEST_LEN + 1);
return rc;
RTR3DECL(int) RTSha256DigestFromFile(const char *pszFile, char **ppszDigest, PFNRTPROGRESS pfnProgressCallback, void *pvUser)
return VERR_INTERNAL_ERROR;
return rc;
double rdMulti = 0;
if (pfnProgressCallback)
return rc;
void *pvBufFree;
if (!pvBuf)
if (pfnProgressCallback)
return rc;
return VERR_INTERNAL_ERROR;
char *pszDigest;
return rc;