|
| 1 | +/** |
| 2 | + * \file md5_alt.h |
| 3 | + * |
| 4 | + * \brief MD5 hw acceleration (hash function) |
| 5 | + * |
| 6 | + * Copyright (c) 2017, STMicroelectronics |
| 7 | + * SPDX-License-Identifier: Apache-2.0 |
| 8 | + * |
| 9 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 10 | + * not use this file except in compliance with the License. |
| 11 | + * You may obtain a copy of the License at |
| 12 | + * |
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + * |
| 15 | + * Unless required by applicable law or agreed to in writing, software |
| 16 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | + * See the License for the specific language governing permissions and |
| 19 | + * limitations under the License. |
| 20 | + * |
| 21 | + */ |
| 22 | +#ifndef MBEDTLS_MD5_ALT_H |
| 23 | +#define MBEDTLS_MD5_ALT_H |
| 24 | + |
| 25 | +#if defined(MBEDTLS_MD5_ALT) |
| 26 | +#include "mbedtls/platform.h" |
| 27 | +#include "mbedtls/config.h" |
| 28 | + |
| 29 | +#include "cmsis.h" |
| 30 | +#include <string.h> |
| 31 | + |
| 32 | +#ifdef __cplusplus |
| 33 | +extern "C" { |
| 34 | +#endif |
| 35 | + |
| 36 | +/** |
| 37 | + * \brief MD5 context structure |
| 38 | + */ |
| 39 | +typedef struct |
| 40 | +{ |
| 41 | + uint32_t total[2]; /*!< number of bytes processed */ |
| 42 | + uint32_t state[4]; /*!< intermediate digest state */ |
| 43 | + unsigned char buffer[64]; /*!< data block being processed */ |
| 44 | + HASH_HandleTypeDef hhash_md5; |
| 45 | +} |
| 46 | +mbedtls_md5_context; |
| 47 | + |
| 48 | +/** |
| 49 | + * \brief Initialize MD5 context |
| 50 | + * |
| 51 | + * \param ctx MD5 context to be initialized |
| 52 | + */ |
| 53 | +void mbedtls_md5_init( mbedtls_md5_context *ctx ); |
| 54 | + |
| 55 | +/** |
| 56 | + * \brief Clear MD5 context |
| 57 | + * |
| 58 | + * \param ctx MD5 context to be cleared |
| 59 | + */ |
| 60 | +void mbedtls_md5_free( mbedtls_md5_context *ctx ); |
| 61 | + |
| 62 | +/** |
| 63 | + * \brief Clone (the state of) an MD5 context |
| 64 | + * |
| 65 | + * \param dst The destination context |
| 66 | + * \param src The context to be cloned |
| 67 | + */ |
| 68 | +void mbedtls_md5_clone( mbedtls_md5_context *dst, |
| 69 | + const mbedtls_md5_context *src ); |
| 70 | + |
| 71 | +/** |
| 72 | + * \brief MD5 context setup |
| 73 | + * |
| 74 | + * \param ctx context to be initialized |
| 75 | + */ |
| 76 | +void mbedtls_md5_starts( mbedtls_md5_context *ctx ); |
| 77 | + |
| 78 | +/** |
| 79 | + * \brief MD5 process buffer |
| 80 | + * |
| 81 | + * \param ctx MD5 context |
| 82 | + * \param input buffer holding the data |
| 83 | + * \param ilen length of the input data |
| 84 | + */ |
| 85 | +void mbedtls_md5_update( mbedtls_md5_context *ctx, const unsigned char *input, size_t ilen ); |
| 86 | + |
| 87 | +/** |
| 88 | + * \brief MD5 final digest |
| 89 | + * |
| 90 | + * \param ctx MD5 context |
| 91 | + * \param output MD5 checksum result |
| 92 | + */ |
| 93 | +void mbedtls_md5_finish( mbedtls_md5_context *ctx, unsigned char output[16] ); |
| 94 | + |
| 95 | +/* Internal use */ |
| 96 | +void mbedtls_md5_process( mbedtls_md5_context *ctx, const unsigned char data[64] ); |
| 97 | + |
| 98 | +#ifdef __cplusplus |
| 99 | +} |
| 100 | +#endif |
| 101 | + |
| 102 | +#ifdef __cplusplus |
| 103 | +extern "C" { |
| 104 | +#endif |
| 105 | + |
| 106 | +#ifdef __cplusplus |
| 107 | +} |
| 108 | +#endif |
| 109 | + |
| 110 | +#endif /* MBEDTLS_MD5_ALT */ |
| 111 | + |
| 112 | +#endif /* md5_alt.h */ |
0 commit comments