sha1.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  * sha1.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include "api.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #define SHA1_SIZE 20
20 #define SHA1_STATESIZE 20
21 #define SHA1_BLOCKSIZE 64
22 
23 #ifdef USE_ESP_CRYPTO
24 
25 #define crypto_sha1_context_t ESP_SHA1_CTX
26 #define crypto_sha1_init ESP_SHA1_Init
27 #define crypto_sha1_update ESP_SHA1_Update
28 #define crypto_sha1_final ESP_SHA1_Final
29 
30 #else
31 
32 typedef struct {
33  uint32_t state[SHA1_STATESIZE / 4];
34  uint32_t count;
35  uint8_t buffer[SHA1_BLOCKSIZE];
37 
41 
42 #endif
43 
46 
47 #ifdef USE_ESP_CRYPTO
48 
49 static inline CRYPTO_FUNC_HMAC(sha1)
50 {
51  ESP_hmac_sha1_v(key, key_len, 1, &msg, &msg_len, digest);
52 }
53 
54 static inline CRYPTO_FUNC_HMAC_V(sha1)
55 {
56  ESP_hmac_sha1_v(key, key_len, count, msg, msg_len, digest);
57 }
58 
59 #else
60 
62 
63 static inline CRYPTO_FUNC_HMAC(sha1)
64 {
65  crypto_sha1_hmac_v(&msg, &msg_len, 1, key, key_len, digest);
66 }
67 
68 #endif
69 
70 #ifdef __cplusplus
71 }
72 #endif
void size_t const void * key
Definition: blake2s.h:33
CRYPTO_FUNC_HMAC_V(sha1)
#define SHA1_BLOCKSIZE
Definition: sha1.h:21
CRYPTO_FUNC_FINAL(sha1)
CRYPTO_FUNC_GET_STATE(sha1)
#define SHA1_STATESIZE
Definition: sha1.h:20
CRYPTO_FUNC_SET_STATE(sha1)
static CRYPTO_FUNC_HMAC(sha1)
Definition: sha1.h:63
CRYPTO_FUNC_INIT(sha1)
CRYPTO_FUNC_UPDATE(sha1)
Definition: sha1.h:32
uint32_t count
Message length in bytes.
Definition: sha1.h:34