Mbed OS Reference
Loading...
Searching...
No Matches
md5_alt.h
Go to the documentation of this file.
1/**
2 * \file
3 *
4 * \brief MD5 message digest algorithm (hash function)
5 *
6 * \warning MD5 is considered a weak message digest and its use constitutes a
7 * security risk. We recommend considering stronger message
8 * digests instead.
9 */
10/*
11 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
12 * Copyright (C) 2019-2020, STMicroelectronics, All Rights Reserved
13 * SPDX-License-Identifier: Apache-2.0
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License"); you may
16 * not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
23 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 *
27 * This file implements STMicroelectronics MD5 API with HW services based
28 * on mbed TLS API
29 */
30
31#ifndef MBEDTLS_MD5_ALT_H
32#define MBEDTLS_MD5_ALT_H
33
34#if defined (MBEDTLS_MD5_ALT)
35/* Includes ------------------------------------------------------------------*/
36#include "hash_stm32.h"
37
38#ifndef MBEDTLS_ERR_MD5_BAD_INPUT_DATA
39#define MBEDTLS_ERR_MD5_BAD_INPUT_DATA -0x00AF
40#endif
41
42#define ST_MD5_BLOCK_SIZE ((size_t) 64) /*!< HW handles 512 bits, ie 64 bytes */
43#define ST_MD5_NB_HASH_REG ((uint32_t)57) /*!< Number of HASH HW context Registers:
44 CR + STR + IMR + CSR[54] */
45
46/**
47 * \brief MD5 context structure
48 *
49 * STMicroelectronics edition
50 */
51typedef struct mbedtls_md5_context {
52 HASH_HandleTypeDef hhash; /*!< Handle of HASH HAL */
53 uint8_t sbuf[ST_MD5_BLOCK_SIZE]; /*!< Buffer to store input data until ST_MD5_BLOCK_SIZE
54 is reached, or until last input data is reached */
55 uint8_t sbuf_len; /*!< Number of bytes stored in sbuf */
56 uint32_t ctx_save_regs[ST_MD5_NB_HASH_REG];
57}
59
60
61#endif /* MBEDTLS_MD5_ALT */
62
63#endif /* MBEDTLS_MD5_ALT_H */
MD5 context structure.