Path: blob/master/thirdparty/mbedtls/include/mbedtls/md5.h
9903 views
/**1* \file md5.h2*3* \brief MD5 message digest algorithm (hash function)4*5* \warning MD5 is considered a weak message digest and its use constitutes a6* security risk. We recommend considering stronger message7* digests instead.8*/9/*10* Copyright The Mbed TLS Contributors11* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later12*/13#ifndef MBEDTLS_MD5_H14#define MBEDTLS_MD5_H15#include "mbedtls/private_access.h"1617#include "mbedtls/build_info.h"1819#include <stddef.h>20#include <stdint.h>2122#ifdef __cplusplus23extern "C" {24#endif2526#if !defined(MBEDTLS_MD5_ALT)27// Regular implementation28//2930/**31* \brief MD5 context structure32*33* \warning MD5 is considered a weak message digest and its use34* constitutes a security risk. We recommend considering35* stronger message digests instead.36*37*/38typedef struct mbedtls_md5_context {39uint32_t MBEDTLS_PRIVATE(total)[2]; /*!< number of bytes processed */40uint32_t MBEDTLS_PRIVATE(state)[4]; /*!< intermediate digest state */41unsigned char MBEDTLS_PRIVATE(buffer)[64]; /*!< data block being processed */42}43mbedtls_md5_context;4445#else /* MBEDTLS_MD5_ALT */46#include "md5_alt.h"47#endif /* MBEDTLS_MD5_ALT */4849/**50* \brief Initialize MD5 context51*52* \param ctx MD5 context to be initialized53*54* \warning MD5 is considered a weak message digest and its use55* constitutes a security risk. We recommend considering56* stronger message digests instead.57*58*/59void mbedtls_md5_init(mbedtls_md5_context *ctx);6061/**62* \brief Clear MD5 context63*64* \param ctx MD5 context to be cleared65*66* \warning MD5 is considered a weak message digest and its use67* constitutes a security risk. We recommend considering68* stronger message digests instead.69*70*/71void mbedtls_md5_free(mbedtls_md5_context *ctx);7273/**74* \brief Clone (the state of) an MD5 context75*76* \param dst The destination context77* \param src The context to be cloned78*79* \warning MD5 is considered a weak message digest and its use80* constitutes a security risk. We recommend considering81* stronger message digests instead.82*83*/84void mbedtls_md5_clone(mbedtls_md5_context *dst,85const mbedtls_md5_context *src);8687/**88* \brief MD5 context setup89*90* \param ctx context to be initialized91*92* \return 0 if successful93*94* \warning MD5 is considered a weak message digest and its use95* constitutes a security risk. We recommend considering96* stronger message digests instead.97*98*/99int mbedtls_md5_starts(mbedtls_md5_context *ctx);100101/**102* \brief MD5 process buffer103*104* \param ctx MD5 context105* \param input buffer holding the data106* \param ilen length of the input data107*108* \return 0 if successful109*110* \warning MD5 is considered a weak message digest and its use111* constitutes a security risk. We recommend considering112* stronger message digests instead.113*114*/115int mbedtls_md5_update(mbedtls_md5_context *ctx,116const unsigned char *input,117size_t ilen);118119/**120* \brief MD5 final digest121*122* \param ctx MD5 context123* \param output MD5 checksum result124*125* \return 0 if successful126*127* \warning MD5 is considered a weak message digest and its use128* constitutes a security risk. We recommend considering129* stronger message digests instead.130*131*/132int mbedtls_md5_finish(mbedtls_md5_context *ctx,133unsigned char output[16]);134135/**136* \brief MD5 process data block (internal use only)137*138* \param ctx MD5 context139* \param data buffer holding one block of data140*141* \return 0 if successful142*143* \warning MD5 is considered a weak message digest and its use144* constitutes a security risk. We recommend considering145* stronger message digests instead.146*147*/148int mbedtls_internal_md5_process(mbedtls_md5_context *ctx,149const unsigned char data[64]);150151/**152* \brief Output = MD5( input buffer )153*154* \param input buffer holding the data155* \param ilen length of the input data156* \param output MD5 checksum result157*158* \return 0 if successful159*160* \warning MD5 is considered a weak message digest and its use161* constitutes a security risk. We recommend considering162* stronger message digests instead.163*164*/165int mbedtls_md5(const unsigned char *input,166size_t ilen,167unsigned char output[16]);168169#if defined(MBEDTLS_SELF_TEST)170171/**172* \brief Checkup routine173*174* \return 0 if successful, or 1 if the test failed175*176* \warning MD5 is considered a weak message digest and its use177* constitutes a security risk. We recommend considering178* stronger message digests instead.179*180*/181int mbedtls_md5_self_test(int verbose);182183#endif /* MBEDTLS_SELF_TEST */184185#ifdef __cplusplus186}187#endif188189#endif /* mbedtls_md5.h */190191192