1 /*
2 * SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6 #include <stdio.h>
7 #include <string.h>
8 #include "mbedtls/md5.h"
9 #include "mbedtls/platform_util.h"
10
11 #if defined(MBEDTLS_MD5_ALT)
12 #include "md/esp_md.h"
13
esp_md5_finish(mbedtls_md5_context * ctx,unsigned char output[16])14 int esp_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] )
15 {
16 esp_rom_md5_final(output, ctx);
17
18
19 return 0;
20 }
21
esp_md5_update(mbedtls_md5_context * ctx,const unsigned char * input,size_t ilen)22 int esp_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen )
23 {
24 esp_rom_md5_update(ctx, input, ilen);
25
26
27 return 0;
28 }
29
esp_md5_init(mbedtls_md5_context * ctx)30 void esp_md5_init( mbedtls_md5_context *ctx )
31 {
32 esp_rom_md5_init(ctx);
33 }
34
esp_md5_starts(mbedtls_md5_context * ctx)35 int esp_md5_starts( mbedtls_md5_context *ctx )
36 {
37 esp_md5_init(ctx);
38 return 0;
39 }
40
esp_md5_free(mbedtls_md5_context * ctx)41 void esp_md5_free( mbedtls_md5_context *ctx )
42 {
43 if (ctx == NULL) {
44 return;
45 }
46
47 mbedtls_platform_zeroize( ctx, sizeof( mbedtls_md5_context ) );
48 }
49
esp_md5_process(mbedtls_md5_context * ctx,const unsigned char data[64])50 int esp_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] )
51 {
52 esp_md5_update(ctx, data, 64);
53
54 return 0;
55 }
56
esp_md5_clone(mbedtls_md5_context * dst,const mbedtls_md5_context * src)57 void esp_md5_clone( mbedtls_md5_context *dst, const mbedtls_md5_context *src )
58 {
59 *dst = *src;
60 }
61 #endif
62