-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc4.h
More file actions
69 lines (60 loc) · 2.71 KB
/
rc4.h
File metadata and controls
69 lines (60 loc) · 2.71 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
#ifndef _LibRc4_h_
#define _LibRc4_h_
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORTS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <stdint.h>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// TYPES
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rc4Context - This must be initialised using Rc4Initialised. Do not modify the contents of this structure directly.
typedef struct
{
uint32_t i;
uint32_t j;
uint8_t S[256];
} Rc4Context;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// PUBLIC FUNCTIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rc4Initialise
//
// Initialises an RC4 cipher and discards the specified number of first bytes.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Rc4Initialise
(
Rc4Context* Context,
void* Key,
uint32_t KeySize,
uint32_t DropN
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rc4Output
//
// Outputs the requested number of bytes from the RC4 stream
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Rc4Output
(
Rc4Context* Context,
void* Buffer,
uint32_t Size
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Rc4Xor
//
// XORs the RC4 stream with an input buffer and puts the results in an output buffer. This is used for encrypting
// and decrypting data. InBuffer and OutBuffer can point to the same location for inplace encrypting/decrypting
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void
Rc4Xor
(
Rc4Context* Context,
void* InBuffer,
void* OutBuffer,
uint32_t Size
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif //_LibRc4_h_