-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd5.h
More file actions
79 lines (67 loc) · 2.94 KB
/
md5.h
File metadata and controls
79 lines (67 loc) · 2.94 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
74
75
76
77
78
79
#ifndef _LibMd5_h_
#define _LibMd5_h_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
#include <stdio.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TYPES
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Md5Context - This must be initialised using Md5Initialised. Do not modify the contents of this structure directly.
typedef struct
{
uint32_t lo;
uint32_t hi;
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
uint8_t buffer[64];
uint32_t block[16];
} Md5Context;
#define MD5_HASH_SIZE ( 128 / 8 )
typedef struct
{
uint8_t bytes [MD5_HASH_SIZE];
} MD5_HASH;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Md5Initialise
//
// Initialises an MD5 Context. Use this to initialise/reset a context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Md5Initialise
(
Md5Context* Context
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Md5Update
//
// Adds data to the MD5 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 Md5Finalise to calculate the hash.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Md5Update
(
Md5Context* Context,
void* Buffer,
uint32_t BufferSize
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Md5Finalise
//
// Performs the final calculation of the hash and returns the digest (16 byte buffer containing 128bit hash). After
// calling this, Md5Initialised must be used to reuse the context.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Md5Finalise
(
Md5Context* Context,
MD5_HASH* Digest
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //_LibMd5_h_