• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdint.h>
22 
23 /**
24  * The MD5 functions calculate a 128-bit cryptographic digest for any number of input bytes.
25  */
26 
27 /**
28  * @brief Type defined for MD5 context
29  *
30  */
31 typedef struct MD5Context {
32     uint32_t buf[4];
33     uint32_t bits[2];
34     uint8_t in[64];
35 } md5_context_t;
36 
37 #define ESP_ROM_MD5_DIGEST_LEN 16
38 
39 /**
40  * @brief Initialize the MD5 context
41  *
42  * @param context Context object allocated by user
43  */
44 void esp_rom_md5_init(md5_context_t *context);
45 
46 /**
47  * @brief Running MD5 algorithm over input data
48  *
49  * @param context MD5 context which has been initialized by `MD5Init`
50  * @param buf Input buffer
51  * @param len Buffer length in bytes
52  */
53 void esp_rom_md5_update(md5_context_t *context, const void *buf, uint32_t len);
54 
55 /**
56  * @brief Extract the MD5 result, and erase the context
57  *
58  * @param digest Where to store the 128-bit digest value
59  * @param context MD5 context
60  */
61 void esp_rom_md5_final(uint8_t *digest, md5_context_t *context);
62 
63 #ifdef __cplusplus
64 }
65 #endif
66