-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathsha256.h
56 lines (47 loc) · 1.62 KB
/
sha256.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SHA256_H
#define SHA256_H
#ifdef __cplusplus
extern "C" {
#endif
// use old api
/**
* \brief Output = SHA-256( input buffer )
*
* \param input buffer holding the data
* \param ilen length of the input data
* \param output SHA-224/256 checksum result
* \param is224 0 = use SHA256, 1 = use SHA224
*/
void sha256( const unsigned char *input, size_t ilen,
unsigned char output[32], int is224 );
/**
* \brief Output = HMAC-SHA-256( hmac key, input buffer )
*
* \param key HMAC secret key
* \param keylen length of the HMAC key
* \param input buffer holding the data
* \param ilen length of the input data
* \param output HMAC-SHA-224/256 result
* \param is224 0 = use SHA256, 1 = use SHA224
*/
void sha256_hmac( const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char output[32], int is224 );
void hmac_256(const unsigned char *key, size_t keylen,
const unsigned char *input, size_t ilen,
unsigned char output[32]);
// provide these for direct access as a lib
typedef struct SHA256Context {
uint32_t state[8];
uint32_t chunk[16];
uint32_t chunk_len;
uint32_t totallen;
} SHA256_CTX;
void SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx);
void SHA256_Update(SHA256_CTX * ctx, const void *in, size_t len);
void SHA256_Init(SHA256_CTX * ctx);
int hkdf_sha256( uint8_t *salt, uint32_t salt_len, uint8_t *ikm, uint32_t ikm_len, uint8_t *info, uint32_t info_len, uint8_t *okm, uint32_t okm_len);
#ifdef __cplusplus
}
#endif
#endif /* sha256.h */