-
Notifications
You must be signed in to change notification settings - Fork 7
/
SHA512.h
27 lines (19 loc) · 841 Bytes
/
SHA512.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
// SHA 512 Implementation by Timothy Vaccarelli
// Based on the hashing algorithm details from http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
// and http://www.iwar.org.uk/comsec/resources/cipher/sha256-384-512.pdf
#ifndef __SHA512_H_
#define __SHA512_H_
#include <inttypes.h>
#include <stdint.h>
#include "SHACommon.h"
#define SHA512_MESSAGE_BLOCK_SIZE 128
#define SHA512_HASH_SIZE 64
#define HASH_ARRAY_LEN 8
#define MAX_VAL 0xFFFFFFFFFFFFFFFFLLU
/// Preprocesses the given message of len bytes
PaddedMsg preprocess(uint8_t *msg, size_t len);
/// Returns the sha-512 hash corresponding to the padded message: Return value must be free()'d
uint64_t *getHash(PaddedMsg *p);
/// Wrapper for hashing methods, up to caller to free the return value
uint64_t *SHA512Hash(uint8_t *input, size_t len);
#endif //__SHA512_H_