md5.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * md5.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include "api.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #define MD5_SIZE 16
20 #define MD5_STATESIZE 16
21 #define MD5_BLOCKSIZE 64
22 
23 #ifdef USE_ESP_CRYPTO
24 
25 #define crypto_md5_context_t ESP_MD5_CTX
26 
27 #define crypto_md5_init ESP_MD5_Init
28 #define crypto_md5_update ESP_MD5_Update
29 #define crypto_md5_final ESP_MD5_Final
30 
31 #else
32 
33 typedef struct {
34  uint32_t state[MD5_STATESIZE / 4];
35  uint32_t count;
36  uint8_t buffer[MD5_BLOCKSIZE];
38 
39 CRYPTO_FUNC_INIT(md5);
42 
43 #endif
44 
47 
48 #ifdef USE_ESP_CRYPTO
49 
50 static inline CRYPTO_FUNC_HMAC(md5)
51 {
52  ESP_hmac_md5_v(key, key_len, 1, &msg, &msg_len, digest);
53 }
54 
55 static inline CRYPTO_FUNC_HMAC_V(md5)
56 {
57  ESP_hmac_md5_v(key, key_len, count, msg, msg_len, digest);
58 }
59 
60 #else
61 
63 
64 static inline CRYPTO_FUNC_HMAC(md5)
65 {
66  crypto_md5_hmac_v(&msg, &msg_len, 1, key, key_len, digest);
67 }
68 
69 #endif
70 
71 #ifdef __cplusplus
72 }
73 #endif
CRYPTO_FUNC_SET_STATE(md5)
static CRYPTO_FUNC_HMAC(md5)
Definition: md5.h:64
CRYPTO_FUNC_INIT(md5)
uint32_t count
Bytes in message.
Definition: md5.h:35
void size_t const void * key
Definition: blake2s.h:33
#define MD5_BLOCKSIZE
Definition: md5.h:21
CRYPTO_FUNC_GET_STATE(md5)
Definition: md5.h:33
#define MD5_STATESIZE
Definition: md5.h:20
CRYPTO_FUNC_UPDATE(md5)
CRYPTO_FUNC_FINAL(md5)
CRYPTO_FUNC_HMAC_V(md5)