-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsha512.h
More file actions
67 lines (57 loc) · 2.55 KB
/
sha512.h
File metadata and controls
67 lines (57 loc) · 2.55 KB
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
57
58
59
60
61
62
63
64
65
66
67
#ifndef _LibSha512_h_
#define _LibSha512_h_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
#include <stdio.h>
typedef struct
{
uint64_t length;
uint64_t state[8];
uint32_t curlen;
uint8_t buf[128];
} Sha512Context;
#define SHA512_HASH_SIZE ( 512 / 8 )
typedef struct
{
uint8_t bytes [SHA512_HASH_SIZE];
} SHA512_HASH;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha512Initialise
//
// Initialises a SHA512 Context. Use this to initialise/reset a context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Sha512Initialise
(
Sha512Context* Context
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha512Update
//
// Adds data to the SHA512 context. This will process the data and update the internal state of the context. Keep on
// calling this function until all the data has been added. Then call Sha512Finalise to calculate the hash.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Sha512Update
(
Sha512Context* Context,
void* Buffer,
uint32_t BufferSize
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha512Finalise
//
// Performs the final calculation of the hash and returns the digest (64 byte buffer containing 512bit hash). After
// calling this, Sha512Initialised must be used to reuse the context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Sha512Finalise
(
Sha512Context* Context,
SHA512_HASH* Digest
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //_LibSha512_h_