2021-10-29 00:39:53 -04:00
|
|
|
/*
|
2022-03-02 23:04:39 -05:00
|
|
|
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
2021-10-29 00:39:53 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2021-04-06 02:21:28 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "esp_rom_md5.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-01-17 21:32:56 -05:00
|
|
|
#if CONFIG_IDF_TARGET_ESP32C2
|
2021-11-06 05:29:29 -04:00
|
|
|
typedef struct mbedtls_md5_context mbedtls_md5_context;
|
|
|
|
#else
|
2021-04-06 02:21:28 -04:00
|
|
|
typedef struct MD5Context mbedtls_md5_context;
|
2021-11-06 05:29:29 -04:00
|
|
|
#endif
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Initialize MD5 context
|
|
|
|
*
|
|
|
|
* \param ctx MD5 context to be initialized
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-28 09:13:32 -04:00
|
|
|
void esp_md5_init( mbedtls_md5_context *ctx );
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Clear MD5 context
|
|
|
|
*
|
|
|
|
* \param ctx MD5 context to be cleared
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void esp_md5_free( mbedtls_md5_context *ctx );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Clone (the state of) an MD5 context
|
|
|
|
*
|
|
|
|
* \param dst The destination context
|
|
|
|
* \param src The context to be cloned
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void esp_md5_clone( mbedtls_md5_context *dst, const mbedtls_md5_context *src );
|
|
|
|
|
|
|
|
/**
|
2021-05-28 09:13:32 -04:00
|
|
|
* \brief MD5 context setup
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
2021-05-28 09:13:32 -04:00
|
|
|
* \param ctx context to be initialized
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \return 0 if successful
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-28 09:13:32 -04:00
|
|
|
int mbedtls_md5_starts( mbedtls_md5_context *ctx );
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
/**
|
2021-05-28 09:13:32 -04:00
|
|
|
* \brief MD5 process buffer
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \param ctx MD5 context
|
2021-05-28 09:13:32 -04:00
|
|
|
* \param input buffer holding the data
|
|
|
|
* \param ilen length of the input data
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \return 0 if successful
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-28 09:13:32 -04:00
|
|
|
int esp_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen );
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
/**
|
2021-05-28 09:13:32 -04:00
|
|
|
* \brief MD5 final digest
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \param ctx MD5 context
|
2021-05-28 09:13:32 -04:00
|
|
|
* \param output MD5 checksum result
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \return 0 if successful
|
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-28 09:13:32 -04:00
|
|
|
int esp_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] );
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
/**
|
2021-05-28 09:13:32 -04:00
|
|
|
* \brief MD5 process data block (internal use only)
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \param ctx MD5 context
|
2021-05-28 09:13:32 -04:00
|
|
|
* \param data buffer holding one block of data
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
2021-05-28 09:13:32 -04:00
|
|
|
* \return 0 if successful
|
2021-04-06 02:21:28 -04:00
|
|
|
*
|
|
|
|
* \warning MD5 is considered a weak message digest and its use
|
|
|
|
* constitutes a security risk. We recommend considering
|
|
|
|
* stronger message digests instead.
|
|
|
|
*
|
|
|
|
*/
|
2021-05-28 09:13:32 -04:00
|
|
|
int esp_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] );
|
2021-04-06 02:21:28 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|