-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsha1.h
More file actions
73 lines (62 loc) · 2.9 KB
/
sha1.h
File metadata and controls
73 lines (62 loc) · 2.9 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
68
69
70
71
72
73
#ifndef _LibSha1_h_
#define _LibSha1_h_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TYPES
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha1Context - This must be initialised using Sha1Initialised. Do not modify the contents of this structure directly.
typedef struct
{
uint32_t State[5];
uint32_t Count[2];
uint8_t Buffer[64];
} Sha1Context;
#define SHA1_HASH_SIZE ( 160 / 8 )
typedef struct
{
uint8_t bytes [SHA1_HASH_SIZE];
} SHA1_HASH;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha1Initialise
//
// Initialises an SHA1 Context. Use this to initialise/reset a context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Sha1Initialise
(
Sha1Context* Context
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha1Update
//
// Adds data to the SHA1 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 Sha1Finalise to calculate the hash.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Sha1Update
(
Sha1Context* Context,
void* Buffer,
uint32_t BufferSize
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha1Finalise
//
// Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After
// calling this, Sha1Initialised must be used to reuse the context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Sha1Finalise
(
Sha1Context* Context,
SHA1_HASH* Digest
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //_LibSha1_h_