api.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  * api.h - Macros for constructing C API for crypto functions
8  *
9  ****/
10 
11 #pragma once
12 
13 #include <sming_attr.h>
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 #ifdef ARCH_ESP8266
18 #define USE_ESP_CRYPTO
19 #include <esp_crypto.h>
20 #endif
21 
22 #define CRYPTO_NAME(hash, name) crypto_##hash##_##name
23 #define CRYPTO_CTX(hash) CRYPTO_NAME(hash, context_t)
24 #define CRYPTO_FUNC_INIT(hash) void CRYPTO_NAME(hash, init)(CRYPTO_CTX(hash) * ctx)
25 #define CRYPTO_FUNC_UPDATE(hash) \
26  void CRYPTO_NAME(hash, update)(CRYPTO_CTX(hash) * ctx, const void* input, uint32_t length)
27 #define CRYPTO_FUNC_FINAL(hash) void CRYPTO_NAME(hash, final)(uint8_t * digest, CRYPTO_CTX(hash) * ctx)
28 #define CRYPTO_FUNC_GET_STATE(hash) uint64_t CRYPTO_NAME(hash, get_state)(CRYPTO_CTX(hash) * ctx, void* state)
29 #define CRYPTO_FUNC_SET_STATE(hash) \
30  void CRYPTO_NAME(hash, set_state)(CRYPTO_CTX(hash) * ctx, const void* state, uint64_t count)
31 
32 #define CRYPTO_FUNC_HMAC(hash) \
33  void CRYPTO_NAME(hash, hmac)(const uint8_t* msg, int msg_len, const uint8_t* key, int key_len, uint8_t* digest)
34 #define CRYPTO_FUNC_HMAC_V(hash) \
35  void CRYPTO_NAME(hash, hmac_v)(const uint8_t** msg, int* msg_len, int count, const uint8_t* key, int key_len, \
36  uint8_t* digest)