-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsha256.h
More file actions
23 lines (18 loc) · 776 Bytes
/
sha256.h
File metadata and controls
23 lines (18 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <stdint.h>
#include "hash.h"
// SHA256 data.
#define SHA256_BUF_OFFSET (4)
#define SHA256_INPUT_BYTES (64) // Input bytes at a time
#define SHA256_SIZE_BYTES (8) // Bytes for internal input size representation
#define SHA256_RESULT_BYTES (32) // Hash result size in bytes
#define SHA256_LSW (1) // Least significant word for size
#define SHA256_MSW (0)
typedef struct {
JOINED H[SHA256_RESULT_BYTES/4];
uint32_t count[SHA256_SIZE_BYTES/4];
} SHA256_CTX;
#define SHA256_MATCH(X,Y) (memcmp((X),(Y),SHA256_RESULT_BYTES))
void SHA256Init(SHA256_CTX *);
void SHA256Update(SHA256_CTX *,char * data,uint16_t length);
void SHA256AddExpandedHash(SHA256_CTX *,uint8_t * data);
void SHA256Final(SHA256_CTX *);