sha2.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  * sha2.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include "api.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /*
20  * SHA224
21  */
22 
23 #define SHA224_SIZE 28
24 #define SHA224_STATESIZE 32
25 #define SHA224_BLOCKSIZE 64
26 
27 typedef struct {
28  uint32_t state[8];
29  uint32_t count;
30  uint8_t buffer[SHA224_BLOCKSIZE];
32 
38 
39 /*
40  * SHA256
41  */
42 
43 #define SHA256_SIZE 32
44 #define SHA256_STATESIZE 32
45 #define SHA256_BLOCKSIZE 64
46 
48 
54 
56 static inline CRYPTO_FUNC_HMAC(sha256)
57 {
58  crypto_sha256_hmac_v(&msg, &msg_len, 1, key, key_len, digest);
59 }
60 
61 /*
62  * SHA384
63  */
64 
65 #define SHA384_SIZE 48
66 #define SHA384_STATESIZE 64
67 #define SHA384_BLOCKSIZE 128
68 
69 typedef struct {
70  uint64_t state[8];
71  uint32_t count;
72  uint8_t buffer[SHA384_BLOCKSIZE];
74 
80 
82 
83 static inline CRYPTO_FUNC_HMAC(sha384)
84 {
85  crypto_sha384_hmac_v(&msg, &msg_len, 1, key, key_len, digest);
86 }
87 
88 /*
89  * SHA512
90  */
91 
92 #define SHA512_SIZE 64
93 #define SHA512_STATESIZE 64
94 #define SHA512_BLOCKSIZE 128
95 
97 
103 
105 
106 static inline CRYPTO_FUNC_HMAC(sha512)
107 {
108  crypto_sha512_hmac_v(&msg, &msg_len, 1, key, key_len, digest);
109 }
110 
111 #ifdef __cplusplus
112 }
113 #endif
void size_t const void * key
Definition: blake2s.h:33
crypto_sha224_context_t crypto_sha256_context_t
Definition: sha2.h:47
CRYPTO_FUNC_UPDATE(sha224)
CRYPTO_FUNC_HMAC_V(sha256)
#define SHA224_BLOCKSIZE
Definition: sha2.h:25
CRYPTO_FUNC_FINAL(sha224)
CRYPTO_FUNC_GET_STATE(sha224)
static CRYPTO_FUNC_HMAC(sha256)
Definition: sha2.h:56
crypto_sha384_context_t crypto_sha512_context_t
Definition: sha2.h:96
#define SHA384_BLOCKSIZE
Definition: sha2.h:67
CRYPTO_FUNC_INIT(sha224)
CRYPTO_FUNC_SET_STATE(sha224)
Definition: sha2.h:27
uint32_t count
Definition: sha2.h:29
Definition: sha2.h:69
uint32_t count
Definition: sha2.h:71