digest.h revision fc659761c3e27dad0ce26752ed131bd4b7763b3b
/** @file
* IPRT - Crypto - Cryptographic Hash / Message Digest.
*/
/*
* Copyright (C) 2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___iprt_crypto_digest_h
#define ___iprt_crypto_digest_h
/** @defgroup grp_rt_crdigest RTCrDigest - Crypographic Hash / Message Digest API.
* @ingroup grp_rt
* @{
*/
/**
* Cryptographic hash / message digest provider descriptor.
*
* This gives the basic details and identifiers of the algorithm as well as
* function pointers to the implementation.
*/
typedef struct RTCRDIGESTDESC
{
/** The message digest provider name. */
const char *pszName;
/** The object ID string. */
const char *pszObjId;
/** Pointer to a NULL terminated table of alias object IDs (optional). */
const char * const *papszObjIdAliases;
/** The IPRT digest type. */
/** The max size of the final hash (binary). */
/** The size of the state. */
/** Reserved. */
/**
* Updates the digest with more data.
*
* @param pvState The opaque message digest state.
* @param pvData The data to add to the digest.
* @param cbData The amount of data to add to the digest.
*/
/**
* Finalizes the digest calculation.
*
* @param pvState The opaque message digest state.
* @param pbHash Where to store the output digest. This buffer is at
* least RTCRDIGESTDESC::cbHash bytes large.
*/
/**
* (Re-)Initializes the digest. Optional.
*
* Optional, RT_BZERO will be used if NULL.
*
* @returns IPRT status code.
* @param pvState The opaque message digest state.
* @param pvOpaque Opaque algortihm specific parameter.
* @param fReInit Set if this is a re-init call.
*/
/**
* Deletes the message digest state.
*
* Optional, memset will be used if NULL.
*
* @param pvState The opaque message digest state.
*/
/**
* Clones the message digest state.
*
* Optional, memcpy will be used if NULL.
*
* @returns IPRT status code.
* @param pvState The opaque message digest state (destination).
* @param pvSrcState The opaque message digest state to clone (source).
*/
/**
* Gets the hash size.
*
* Optional, if not provided RTCRDIGESTDESC::cbHash will be returned. If
* provided though, RTCRDIGESTDESC::cbHash must be set to the largest possible
* hash size.
*
* @returns The hash size.
* @param pvState The opaque message digest state.
*/
/**
* Gets the digest type (when enmType is RTDIGESTTYPE_UNKNOWN).
*
* @returns The hash size.
* @param pvState The opaque message digest state.
*/
/** Pointer to const message digest details and vtable. */
typedef RTCRDIGESTDESC const *PCRTCRDIGESTDESC;
/**
* Finds a cryptographic hash / message digest descriptor by object identifier
* string.
*
* @returns Pointer to the message digest details & vtable if found. NULL if
* not found.
* @param pszObjId The dotted object identifier string of the message
* digest algorithm.
* @param ppvOpaque Where to return an opaque implementation specfici
* sub-type indicator that can be passed to
* RTCrDigestCreate. This is optional, fewer
* algortihms are available if not specified.
*/
/**
* Finds a cryptographic hash / message digest descriptor by object identifier
* ASN.1 object.
*
* @returns Pointer to the message digest details & vtable if found. NULL if
* not found.
* @param pszObjId The ASN.1 object ID of the message digest algorithm.
* @param ppvOpaque Where to return an opaque implementation specfici
* sub-type indicator that can be passed to
* RTCrDigestCreate. This is optional, fewer
* algortihms are available if not specified.
*/
/** @} */
#endif